Answer the question
In order to leave comments, you need to log in
Why doesn't it completely change props?
ran into an odd problem.
Here I have such a structure state prntscr.com/ckmzj6
reducer looks like this (this is the action of changing the structure)
const structure = state.structure;
const { parentId, value, key } = action;
const nodeId = Object.keys(structure).length;
structure[nodeId] = {
id: nodeId,
_key: key,
_value: value,
type: 'string',
childIds: []
};
structure[parentId]._value = false;
structure[parentId].type = "object";
structure[parentId].childIds.push(nodeId);
console.log(structure[parentId]);
return {
...state,
structure: structure
};
structure[parentId]._value = false;
structure[parentId].type = "object";
Answer the question
In order to leave comments, you need to log in
Your problem is that you are mutating the object. redux, like react, is built on immutability. I gave you an example of how to do it .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question