Client-side store memoization not working with hot module reloading
See original GitHub issueWhen navigating to a different page in our app we see the following warning:
We believe that this is caused by using both withRedux
and connect
. The store is memoized in the module scope here but then HMR reloads the module, which creates another store instance:
[HMR] Updated modules:
[HMR] - ./~/next-redux-wrapper/src/index.js
...
We initially thought that this might be related to using a _document.js
template with next.js, especially after seeing this comment, but removing _document.js
didn’t solve our issue.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Client Side Rendering using Layouts without Reloading the ...
A position fixed siderbar not working when route changed with "Link" ... How do I achieve client side component based (lazy-load?) routing?
Read more >Webpack hot module replacement in server code
Hot reloading server middleware bundled with Webpack is actually much easier than hot reloading client side bundles for two reasons:.
Read more >SSR: Dependency mocking is the answer! - HackerNoon
And yes – some companies use puppeteer to do a “server” render, as long as their application constructed to work only from “client...
Read more >Memoization Forget-Me-Bomb. Remember it? No! - ITNEXT
A Big Problem. const tasks = getTasks(state); // let's get some data from state1 (function was defined above) getDataFromTask(tasks[ ...
Read more >Hot Module Replacement in Redux - Toptal
I've yet to run into problems with Redux and HMR, but if I do I know I can hot reload redux reducers as...
Read more >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
Published.
I suspect that window hack will be the default behavior, I suggest to name the property like
__NEXT_REDUX_STORE__
or something similar… Don’t hesitate to send a PR 😃The lib itself should not be hot-reloaded, because it does not change so referentially it should always be one object. Anyway,
window
fix should be just fine.I have pushed a quick fix for you guys, you can install master branch and use it right away.