I have an issue with react when I want to change the selected option. The problem is that the value is an object and I can\'t pass it in option value attribut.
See t
You can make use of index of options
class Selector extends React.Component {
contructor(props) {
super(props);
this.state = { obj: null }
this.handleChange = this.handleChange.bind(this)
}
handleChange(e) {
this.setState({obj: this.props.listOption[e.target.value].obj})
}
render() {
}
}
Moreover, I set obj in state as null in the constructor Is there a right way to do it?
I depends on your requirement. If you want to show at least one option as selected you can keep that instead of null