Question: Trying to update one element of an array in this.state I'm getting an (expected ,) error but cant see where I've gone wrong. Do I need to create a temporary array update that, then assign the whole array back to the state

This is essentially what I have

```
this.state = { array: ['a', 'b', 'c'] };

onBack() {
  this.setState({
      array[2]: 'something' 
  });
}

```

Answer: 
If you are bother to set the new updated array on your `currentArray` using spread function, you may use `Array.from(duplicateArray)`

```
let duplicateArray = [...currentArray] //duplicate the array into new array
duplicateArray[index].value = 'x'; // update the field you want to update
setCurrentArray(Array.from(duplicateArray )) //set the new updated array into currentArray

```

I bother with this issue and I just search about and I saw this idea, and it works!
<https://github.com/facebook/react-native/issues/21734#issuecomment-433885436>
***Create a temporary array update that, then assign the whole array back to the state***

```
var arr = [];
arr = this.state.array;
arr[2] = "something";
this.setState({
    array : arr
});

```