I'm using react native. Suppose I've this state:
{
persons: [{
name: "Person",
id: 0,
value: "",
percent: 50,
messed: false
},
{
name: "Person",
id: 1,
value: "",
percent: 50,
messed: false
}]
}
I want to update, say, percent of id 1. How do I do it with this.setState
? I can deep clone persons object every time and update it but I need to do it a lot of times and the persons object is quite large anyway so it's not performance-wise efficient.
Currently I'm doing
this.state.persons[id].percent = 0;
this.forceUpdate();
which seems not so react-ish. How do I go about this?