Pattern: Use of createReactClass
instead of ES6 class
Issue: -
ES6 classes provide a more modern and standardized way to create React components compared to the legacy createReactClass
method. Using ES6 classes improves code consistency and takes advantage of JavaScript's built-in class features.
Example of incorrect code:
var Hello = createReactClass({
render: function() {
return <div>Hello {this.props.name}</div>;
}
});
Example of correct code:
class Hello extends React.Component {
render() {
return <div>Hello {this.props.name}</div>;
}
}