I'm trying to make multiple selection-inputs using React and react-select.
How can I manage elements with multiple states?
I make elements using loop (map) and after that how can I determine what value is going to be the next value for value prop?
How can I somehow save values that I got from onChange callback as states, and then assign it to proper element?
Now whenever I change my input (onChange calls handleChange), it's saving current selected value (as expected) but when I change input in another element, the previous element value goes back to "", and I'm only changing values in the current one.
handleChange(el) {
this.setState({
value:el
})
}
let options = values.map(value => {
return {
value: value.name,
label: value.name,
category: el,
categoryName: data[el].name
}
})
<Select
name={el}
className='Select-filters'
closeOnSelect={false}
onChange={this.handleChange}
noResultsText='Filter couldn't be found'
placeholder={`Search ${nameNotCapitalized}`}
options={options}
delimiter=';'
simpleValue
value={value}
multi
/>