Answer the question
In order to leave comments, you need to log in
Is it the right way to update data in a reducer?
There is such a nesting in the reducer. key1_id1 and subkey1_id1 are id values, there can be many such values
{
key1_id1: {
subkey1_id1: {
bd: {
isLoading: false,
data: {}
}
}
}
}
action.payload.key='key1_id1';
action.payload.subkey='subkey1_id1';
action.payload.data="какой-то объект";
case UPDATE_DATA:
return Object.assign({},state,
{
[action.payload.key]: Object.assign(
{},
state[action.payload.key],
{[action.payload.subkey]:
Object.assign(
{},
(state[action.payload.key])?state[action.payload.key][action.payload.subkey]:{},
action.payload.data
)
}
)
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question