Creating classes
We have seen in the first chapter how React uses elements to display the components on the screen.
Let's now look at the different ways in which we can define our components with React and the reasons why we should use one or other technique.
Again this book assumes that you've already played with React in a small/medium application which means that you must have created some components before.
You may have chosen one method according to the examples on the React website or by following the style of the boilerplate you used to scaffold the project.
Concepts such as props, state, and life cycle methods should be clear at this point, and we are not going to look at them in detail.
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 />...