The createClass factory

Looking at the React documentation (at the time of writing), the first example we find shows us how to define components using React.createClass.

Let's start with a very simple snippet:

  const Button = React.createClass({ 
render() {
return <button />;
}
});

With the preceding code, we created a button, and we can reference it inside other components in our application.

We can change the snippet to use plain JavaScript as follows:

  const Button = React.createClass({ 
render() {
return React.createElement('button');
}
});

We can run the code everywhere without needing to use Babel for transpiling, which is a good way to start with React, avoiding the effort of learning different tools in the React ecosystem.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.200.211