We Jumped the Gun Moving React Components to ES2015 Class Syntax
Jacques Favreau
60537

Well, for the propTypes on top I’d say that’s an easy one. If you don’t want to go with stage-2 features you can define them at the top using const and at the bottom use them. It is some extra code, but not such a big deal I’d say. I’ve forked your gist to show how that would look like: https://gist.github.com/ivanalejandro0/7dabf4c1a6a2d134579dae69b0822312

Regarding binding, the es6 classes require the user to explicitly bind functions in order to be used by handlers (or anything other than this.theFunction() I’d say). I’m ok with solving it using arrow functions and public class attributes, so for me is not really a problem. But I do agree that other alternatives are not that nice (and even bug prone).

Anyway, the really good thing on this matter (imho) is that forces developers to learn what this is and how it works, also how to properly bind functions and why. Many developers don’t get to understand those topics enough because they “don’t need it” and this change, from createClass implicitly binding everything to an actual class that requires you to bind it, kind of forces you to learn.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.