redux-cookies-middleware icon indicating copy to clipboard operation
redux-cookies-middleware copied to clipboard

Multiple nested paths only return first path.

Open vikashtank opened this issue 4 years ago • 2 comments

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" } }

vikashtank avatar Aug 31 '19 20:08 vikashtank

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);

mamcgrath avatar Sep 30 '19 14:09 mamcgrath

This was actually fixed in the #56.

jancama2 avatar Apr 17 '20 06:04 jancama2