question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Client-side store memoization not working with hot module reloading

See original GitHub issue

When navigating to a different page in our app we see the following warning: bildschirmfoto 2017-05-22 um 15 20 19

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:closed
  • Created 6 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kirill-konshincommented, Jun 21, 2017

Published.

1reaction
kirill-konshincommented, May 30, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found