Suppose if I have 100 objects and each maps to 100 different DOM components. Which of the following coding practice helps react setState() save work:
Practice 1:
this.state={allObj: {"one": true, "two": true, "three": false, "four": true}}
updateState(val,key){
var tmpobj=this.state.allObj;
tmpobj[key]=val;
this.setState({allObj: tmpobj})
}
OR
Practice 2:
this.state ={
one: true,
two: true,
three: false,
four: true
}
updateStateOne(val)
{
this.setState({one: val})
}
updateStateTwo(val)
{
this.setState({Two: val})
}