-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module is remove, when clicking react router links, inside the same module #79
Comments
Hi, thanks for using our library! How have you added the 'contract' module to your store? Are you using the DynamicModuleLoader component to add it? I am not 100% sure about how ReactRouter works, but if you have one route which renders DML with the contract module, and switch to another route that doesn't, the 'contract' module will be removed because the DML component was unmounted. If you want a module that is present for the entire life of the store, add it as an argument to |
Hi Abettadapur <DynamicModuleLoader modules={[getContractModule()]}>
(...)
</DynamicModuleLoader> for each endpoint, to be sure that the module logic (redux and saga) is loaded. We dont want all content to be loaded from the start (or life the entire session), Yes, react-router unload one DynamicModuleLoader but it then load another DynamicModuleLoader (We do have shared modules that are added directly in the createStore) Do you have any suggestion to how we can achieve this? Is there another way to use the DynamicModuleLoader where we dont need one for each endpoint, best regards Alf |
So you want to keep the module in store, when the component that added it to store unmounted? |
No it's not what we optimal want. Right now the module is removed, Just to understand: I will try to make a codesandbox with the problem, but it will take a little time to create, |
Thanks for working with us on this, the module should be reloaded if a new DML is mounted with same module. |
Hey, If you have the Redux Chrome plugin in enabled, We can see that this is whats actually happening:
The page is loadet correct with data from the store loaded by the module
Now an Error occur telling os that it cannot compile the Page2, This error is the reason why we missing: But this means that the Page 2 is compiled before the module is loaded (again) const DynamicPage2 = () => (
<DynamicModuleLoader modules={[getModule1()]}>
<Page2 />
</DynamicModuleLoader>
); This could be because rect-loadable somehow tries to compile this DynamicPage2 and Page2, Or it means that DynamicModuleLoader is compiling (call render) before the module is loaded! Is this a totally wrong approach to use your DynamicModuleLoader? How would you normally do the lazy loading of components? (I know you maybe not using rect-loadable but some other lazy load module) I will take a look at react-loadbale source code, but it does not make sense that it would not deletage the react 'children' compiling to the root react component (In this case DynamicModuleLoader) |
I see a different issue here, Seems like store do not have state when the first module is unloading, note mapStatesToProps is failing on Unmount of the first page (In this repro I first visited Page2). I need to spend more time to debug and see why the store do not have right state. Uncaught TypeError: Cannot read property 'testValue' of undefined |
Hello! |
@RavilM I did not get time to further debug this. |
@abettadapur @navneet-g |
I am having this exact same issue. My problem is as follows. 2 pages: Go to Expected result: Actual Result: Symptom Issue Workaround <DynamicModuleLoader key='loader1' modules={[myModuleDefinition]}>
<MyChildComponent />
</DynamicModuleLoader> |
Hey,
Maybe there is something I dont know of the inner workings,
But when I have a ReactRouter NavLink that point to another page,
within the same module, a
'@@Internal/ModuleManager/ModuleRemoved'
is still dispactehed, which remove the data for the module,
and break our site.
When I hard reload the browser the module is again loadet correct.
So it seems that react router links dont really works inside a module ?
It seems like a bug?
Is it posible to turn of 'ModuleRemoved' ?
Redux history:
The text was updated successfully, but these errors were encountered: