rehydratedState is not recalculated on UPDATE_ACTION
See original GitHub issuerehydratedState is defined only on INIT_ACTION. When localStorage is updated and then lazy-module is loaded, UPDATE_ACTION called and old state (rehydratedState from INIT) is used.
if ((action.type === INIT_ACTION || action.type === UPDATE_ACTION) && rehydratedState) { nextState = merge({}, nextState, rehydratedState); }
Use case:
- Login => token is saved in localstorage
- Reload the page => rehydratedState created with token
- Login with different user => new token stored in localstorage (but not synced with rehydratedState!)
- Go to lazy loaded page => UPDATE_ACTION, token is overridden with old token from step 2 😦((
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:19 (3 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If you want to skip all
UPDATE_ACTION
actions and don’t want to wait for this PR to be merged, there’s a simple way to do it. Replace your local storage sync reducer with a variant of this:@dimitriy-k Have you forked the project? I don’t see it in your GitHub profile. Make sure you’re not cloning this project but rather made a fork and cloned that.