I am using react-redux toolkit and have state as object stored in redux store. On action dispatch I can see that the target key object and its parent are changed in the redux store (from redux dev tools)
But react doesnt rerender the target component and its parent too.
redux toolkit uses immer so I am assuming mutating fields in the object will trigger state change
initialState : {},
//dispatch from api data to update initial state
dispatch( setData({'a' : { some fields}, 'b': {}, 'c': {}}))
//on action in child component
dispatch( updateData (..)
updateData(state, action) {
const targetNode = state.foo[action.payload.targetId);
targetNode.status = 'x';
const parent = state.foo[targetNode.parentId];
parent.status = 'x' //both parent and targetNode are in the state
}
Selector
export const selectNode = (state, nodeId) => {
return state.foo[nodeId] };
export const selectStatus = createSelector( [selectNode],
(node) => {
return node ? node.status : null}
);
selectStatus is used in the component dom