I have an object as array which is store in variable
0 : {option: "E", primary: "primary", color: "#4CAF50"}
1 : {option: "B", primary: "primary", color: "#4CAF50"}
2 : {option: "", color: "", primary: ""}
3 : {option: "", color: "", primary: ""}
4 : {option: "", color: "", primary: ""}
5 : {option: "", color: "", primary: ""}
My question how can I update specific key object without change at all this is my code
handleChange = (index, option) => {
let navNumber = this.state.navNumber
navNumber[index] = {
option:option,
primary:'primary',
color:'#4CAF50'
}
this.setState({navNumber})
};
changeRagu = (index) => {
let navNumber = this.state.navNumber
navNumber[index] = navNumber[index].color = '#FF9800'
this.setState({navNumber})
}
All I want is to update only color by specific index without make all color still empty become same