Recently I learn about you can handle multiple input event using dynamic state.
If have state like this
this.state = {
name_1: 'john',
name_2: 'james'
}
I can get my state like this
[1,2].forEach(obj, i), => (
console.log(this.state[`person_${i}`]);
))
But what about setState? What is the syntax like? I used this and it worked.
//says i is dynamic
this.setState({
[`person_${i}`]: ''
})
Why above code work? it look like array.