I have some state
state = {
theme: {
background: { bgType: 'colour', value: '#449dc7' },
primary: '#4d5a66',
secondary: '#476480',
},
};
When I try and update a nested property such as background
I call setState
as follows
this.setState(prevState => ({
...prevState,
theme: { background: { bgType: 'colour', value: color.hex } },
}));
This however just replaces the state with
theme: { background: { bgType: 'colour', value: color.hex } },
I lose the other properties