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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With