I have a bunch of JSON with multiple objects, arrays, strings, booleans, numbers etc. which are stored in one object at the root level and component.
Here is a sample:
{
"theme": {
"auto": {
"sensor": "sensor.sn1_ldr",
"below": 600
},
"ui": {
"cards": {
"round": false,
"elevation": 1
}
},
...
},
...
}
I have managed to pass back the path and new value of the item in an array like so:
["theme", "auto", "sensor"]
How do I from there set the new value of that path? ie. the equivalent of:
config.theme.auto.sensor = newValue;
but using the path array passed back?
Method I have so far:
handleConfigChange = (path, value) => {
console.log(path, value);
let config = this.state.config;
// Set the new value
this.setState({ config });
};