You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and I don't have any initial state (after all, I'm trying to read it from cookies), so I simply pass an empty object as the initial state:
constinitialState=getStateFromCookies({},paths);
it will break, because in https://github.com/grofers/redux-cookies-middleware/blob/master/src/getStateFromCookies.js#L42 it will get undefined as stateTree and it will try to call stateTree[terminalKey] (assuming that the right side, i.e. JSON parsing, actually succeeds). Couldn't it simply create these keys if they don't exist yet? Otherwise I need to model my initial state like this:
First of all, thanks a lot for this middleware!
I have 2 issues trying to set it up, though:
The first one is that
getStateFromCookies
tries to parse cookie value as JSON (https://github.com/grofers/redux-cookies-middleware/blob/master/src/getStateFromCookies.js#L48), but I'm storing plain strings (e.g. JWT tokens) in my cookies. Why does it try to parse it as a JSON?The second one is related to initial state. Assuming that I've got paths for this middleware set up as:
and I don't have any initial state (after all, I'm trying to read it from cookies), so I simply pass an empty object as the initial state:
it will break, because in https://github.com/grofers/redux-cookies-middleware/blob/master/src/getStateFromCookies.js#L42 it will get
undefined
asstateTree
and it will try to callstateTree[terminalKey]
(assuming that the right side, i.e. JSON parsing, actually succeeds). Couldn't it simply create these keys if they don't exist yet? Otherwise I need to model my initial state like this:to prevent this issue.
The text was updated successfully, but these errors were encountered: