I\'m looking to modify and array in react and insert elements on specific index. This is how my state looks like:
this.state = {arr: [\'\', \'\', \'\', \'\' ]} <
UPDATE
Just use Object.assign() as suggested here to make a copy of your state.
Thus, you can do it as follows :
let new_state = Object.assign({}, this.state); let a = new_state.arr; a[index] = "random element"; this.setState({arr: a});
Hope it helps.