I have an array of components which each have component details and I'm trying to update a detail for a component.
I know I can do this
this.setState({
component: {
...this.state.component,
[var]: value
}
});
but I need to be able to do this
this.setState({
component[key]: {
...this.state.component[key],
[key2]: value
}
});
which fails. How can I modify a sub array without modifying state and replacing the whole thing?