![]() The super call invokes the same function in the parent class, in this case the constructor of React.Component. Which means that for the buyMoreBeer clickhandler below to work. The most common caveat to run into is likely that with ES6 classes, methods aren't autobound to the instance. Most of this has been covered to death in the-difference-between-ES6-classes-and-createClass style posts, but here I'll focus on why I feel that the ES6 class syntax is inferior to React.createClass. In this post I'll go over my main gripes about ES6 classes: But I personally prefer React.createClass over ES6 classes even though I use all other ES6 bells and whistles! In other words, if you don't have a transpiler in your build step, use React.createClass, otherwise use ES6 classes. The official React docs make it very clear that ES6 classes is the recommended way, by introducing React.createClass under the demeaning headline React without ES6. The simpler ones can be pure functions, while the rest can be expressed either as ES6 classes inheriting from React.Component, or as calls to React.createClass. In React there are three different ways to define components.
0 Comments
Leave a Reply. |