I am trying to change from React.createClass to React.Component, but I am getting below error.
Uncaught TypeError: Cannot read property \'state\' of undefined
<
You need to bind your onSelect
to the class in the constructor:
constructor(props) {
super(props);
this.state = {
selected: props.selected // use props, not this.props
};
this.onSelect = this.onSelect.bind(this);
}
The extends
syntax no longer has autobinding like createClass
did.