Using React & Redux here:
My State
looks something similar to this:
State : {
First : {
prop1 : "a",
prop2 : "b"
},
...
Last : {
prop1 : "c",
prop2 : "d"
}
}
My Reducer
function looks like this:
const tabsState = ( state = initialTabState, action ) => {
switch( action.type ) {
case( ENABLE_TAB ):
return (
Object.assign( {}, state, action.payload )
);
default:
return state;
}
};
For the action.payload
, I only want to send data containing new values for prop1
. My understanding of Object.assign
is that the sources
parameters only update the props, they do not over-write the objects in state, is that correct?
In the above, My action.payload is similar to this:
First : {
prop1 : "z"
},
Second : {
prop2 : "x"
},
...
It seems to be overwriting the First
& subsequent objects within the State object. That is to say, that the new State returned by the Reducer
does not have the 2nd prop of each object. prop2
s