Answer the question
In order to leave comments, you need to log in
How to partially change the state of redux?
Hi everyone, this is the current situation.
{
... ,
user : { ... } ,
...
}
function reducer(state, action){
switch (action.type){
...
case 'CHANGE_USER_DATA':{
return {
...state,
user : {
...state.user,
action.prop : action.value
}
}
}
...
}
}
Answer the question
In order to leave comments, you need to log in
return {
...state,
user : {
...state.user,
[action.prop] : action.value
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question