redux-cookies-middleware
redux-cookies-middleware copied to clipboard
Multiple nested paths only return first path.
getStateFromCookies function when given the two nested paths only returns a first path.
Input: const paths = { "authentication.refreshToken": { name: 'refreshToken' }, "authentication.accessToken": { name: 'accessToken' }, };
Call: getStateFromCookies({}, paths}
output: { authentication: { accessToken: "fakeToken" } }
It looks like this is due to how to the state objects are merged.
return pathStates.reduce((finalState, pathState) => ({ ...finalState, ...pathState }), preloadedState);
This would not be hard to fix to using lodash merge or JQuery extend although it would add another dependency.
return pathStates.reduce((finalState, pathState) => _.merge({}, finalState, pathState), preloadedState);
This was actually fixed in the #56.