I want to take multiple input separated by comma from user using one input field.
I used onChange function to store the user input in a state variable. It is storing each letter in each array index.
For example, If I enter Red,Blue as input, it is storing like
Array[0]= R
Array[1]= e
Array[2]= d
Array[3]= ,
Array[4]= B
Array[5]= l
Array[6]= u
Array[7]= e
I want to store them like
Array[0]= Red
Array[1]= Blue
This is what my onChange handler look like:
changeHandler=(event)=> {
this.setState({
[event.target.name]:event.target.value
})
}
How can I do that? I'm new to react js, any help would be appreciated. Thank you.
onChangefunction code.split('')instead of a.split(',')..split(',')now, its working. thank you