microsoft / redux-dynamic-modules

Modularize Redux by dynamically loading reducers and middlewares.
https://redux-dynamic-modules.js.org
MIT License
1.07k stars 116 forks source link

State lost, when moving from one module to another module #177

Closed jeevasusej closed 3 years ago

jeevasusej commented 3 years ago

I am using DynamicModuleLoader. When I move one component/module to another component/module (one route to another route), I lost state from the redux store which already loaded. This makes me not to use the feature of redux (where we have one store shared through out the application). What should I do to maintain redux state once loaded?

We can see that, whenever route change the state has been reset. The store doesn't retain the old state. The state has been added and removed automatically.

2021-05-20_16h24_14

jeevasusej commented 3 years ago

Sorry, the mistake is mine. Dynamic Module Loader concept is "When component is unmounted, the module will be removed from the store and the state will be cleaned up". So the logic is working as expected. I have used moduleStore.addModule(createModuleA()); instead of dynamic module loader. The concept is working as expected.