I need to create Select components based on a list of selects that i have, for example:
List -> item1, item2
The component :
<Select
value={this.state."NAME OF THE ITEM ON THE LIST"}
onChange={this.handleChange}
<MenuItem value={X} key={X} > Something </MenuItem> (the MenuItem part is working)
</Select>
Since the select component needs a value and i need that value to be a state, so when it gets clicked it will call the method handleChange and will update the state like this:
handleChange = (event) => {
this.setState({
"THE NAME OF THE ITEM ": event.target.value(this comes from the MenuItem)
});
};
How can i create the state dynamically so if i have a list with X itens it will create X selects and X states to be updated?