I use react redux (with immer) to store the options and styles of my app after the initialization. How can I change the update function to update specific styles/options of the app, without changing the other options/styles ?
// reducer.js
export const common = produce((draft, action) => {
if (!draft) {
return {
settings: {},
};
}
switch (action.type) {
case STORE_WIDGET_SETTINGS:
draft.settings = action.payload.settings;
return;
case UPDATE_WIDGET_SETTINGS:
draft.settings = action.payload.settings;
return;
default:
return;
}
});
The update function should only update the options/styles states without changing the current options/styles.
Example: Settings before update:
options: {
selector: '#root'
},
styles: {
mainContainer: {
backgroundColor: 'black',
color: 'white',
}
}
Call update function with option:{selector: '#container'}.
The settings should be changed to:
options: {
selector: '#container'
},
styles: {
mainContainer: {
backgroundColor: 'black',
color: 'white',
}
}