I am trying to update only one element in an array state but i am not sure of how to do it.
State
constructor(props) {
super(props);
this.state = {
markers: [],
};
}
Setting the state
setCurrentLocation() {
var root = this;
root.setState({
markers: [
...root.state.markers,
{
coordinate: {
latitude: parseFloat(root.state.currentLat),
longitude: parseFloat(root.state.currentLon)
},
key: root.state.currentLat,
image: pinCurrentLocation
},
],
});
}
If i want to change the key in the fourth element of marker, how do i do that?
Thanks