We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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?
getStateFromCookies
The second one is related to initial state. Assuming that I've got paths for this middleware set up as:
const paths = { 'auth.id_token': { name: 'auth_id_token' }, };
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:
const initialState = 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:
undefined
stateTree
stateTree[terminalKey]
let initialState = { auth: { id_token: null }, }; initialState = getStateFromCookies(initialState, paths);
to prevent this issue.
The text was updated successfully, but these errors were encountered:
@szimek Sorry for the delay in reply. We are glad you found the middleware useful. Regarding your issues.
Sorry, something went wrong.
#51 handles the above mentioned issues
Issue fixed with PR #51
No branches or pull requests
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: