How to change value in array with index in react native

Viewed 14565

I have an array in my state:

state = {
  some_array: [1,1,1,3,6,3,6,23], // sorry for the syntax it's changed
 }
 
 

Now I want to change value in that array that has index let's say 4, and in this case that would be number 6, or if I want to change index 1, that would be second number or array.
I know this is probabbly very simple but I'm just very confused.

If you need more info please comment.

Thanks!

1 Answers

I think that you can to use next code:

const some_array = [...this.state.some_array]
some_array[indexHere] = yourValue
this.setState({some_array:some_array})

This example --- true way for FP in react.

Related