HYDRATE and redux-dynamic-modules
See original GitHub issueHi,
I work on a pretty complex next.js app that uses redux-dynamic-modules. Since I’ve updated next.js to 9.3 (now 9.4) I wanted to migrate from getInitialProps
to getServerSideProps
but I’m a bit confused about the requirement of the HYDRATE
action. Does every reducer (my app has like 50+ of them) need do be able to handle that action? Is there any way to abstract it? My global redux state stores deeply nested objects so having each reducer spread through each and every field and update them with payload would be quite annoying.
Thanks.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Strategies for hydrating a store from SSR #47 - GitHub
The set of loaded modules is effectively part of the Redux store's state, but one that hasn't been serialized from server to client....
Read more >Redux Dynamic Modules
redux -dynamic-modules is a library that aims to make Redux Reducers and middleware easy to modular-ize and add/remove dynamically.
Read more >Redux store code splitting with sagas - Scite
The Redux documentation mentions that you can dynamically inject reducers using the built in replaceReducer function, and includes some ...
Read more >React 18: Hydration failed because the initial UI does not ...
I am using the react-use-cart module and it seems it has issues with react @18.0.0 . I am not sure how this is...
Read more >Redux Store | Shakacode
This redux API is no longer recommended as it prevents dynamic code splitting ... function appStore(props, railsContext) { // Create a hydrated redux...
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
Yes, you’ve pinpointed the exact reason why action constants are residing in separate files, although it’s quite tempting to put reducer, constants and action dispatchers all in one file, there are reasons not to do it.
Like I said, I am really against anything that can lead to inconsistent state, and dynamically loaded reducers is the number one reason to end up in endless debugging.
I’m not sure. Like I said previously, top level hydration handler is the best bet. To be completely honest, I don’t see a value to code split reducers, as it ruins the state consistency (just like in your case). Potentially actions may be handled anywhere and if the needed reducer was not loaded the action won’t be handled. Reducers are small, so what’s the point to code split them?