if I have an array of object like this
[{name: 'james', name: 'john'}] and I know the index of john and want to change the value of john I'll do
person = person.map((p, i)=>i===index?({...p, name: 'changed john'})):p)
this.setState({person})
but what if the array is like this?
['james', 'john']
map, you just doperson[index] = ....const arr = ['james','john'], then you just doarr[0] = 'Sam'and then you'll have['Sam','john']... You don't need to map. Just use array indexes. developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…