I am quite new to React and have been reading up a lot about it. I have come across three different methods to create components:
Functional Components:
const Hello = ({world}) => {
return (
<div>{"Hello" + world}</div>
);
}
React.createClass (Factory):
const Hello = React.createClass({
render: function() {
return <div>{"Hello" + this.props.world}</div>
}
});
ES6 Class Extends
class Hello extends React.Component {
render() {
return (
<div>{"Hello" + this.props.world}</div>
);
}
}
Apart from the obvious that the functional components don't have any state coupled to it and is probably a more functional approach to doing components, why would I use the different methods?
In the React documentation they use all three methods. Some of the Stack Overflow articles suggest the Class method and then some suggest the Factory method.