Skip to content
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

withInjectedReducers not working with Module Federation (still seeing previous state) #22

Open
nkalinov opened this issue Jun 2, 2022 · 2 comments

Comments

@nkalinov
Copy link

nkalinov commented Jun 2, 2022

Hi and thank you for your contributions to the open-source community!

I've tried this lib with react-redux^7.2.8 + withInjectedReducers HOC from the README.md and it works great.
Under Module Federation though the same code doesn't work - the getState() call in withInjectedReducers is still seeing the previous state. I have a console.log at inject time and it's injected before the rendering occurs but still in the HOC injectedReducers doesn't have the newly added one.
To note that I'm trying to import a lazy local file (not from a federated module!).

I've read reduxjs/react-redux#1126 but I am out of ideas why that might occur.
@Ephem's solution is a bit different and it works I guess because the new slice is generated just in time instead of relying on getState() but I don't want to attach my reducers (or ducks) to a specific component but rather inject them at import time.

Any help appreciated.

@nkalinov nkalinov changed the title withInjectedReducers not working (still seeing previous state) withInjectedReducers not working with Module Federation (still seeing previous state) Jun 2, 2022
@GuillaumeCisco
Copy link
Owner

Hello,

Ah this repository brings back memory.
Currently I don't have much time to work on it.
But back in the days, before all this mess about hooks, things were far easier.

I would need to dig a lot in the new code to understand what is going on.

Can you provide me some links about Module Federation please? I will have a quick look.

@nkalinov
Copy link
Author

nkalinov commented Jun 3, 2022

You can find plenty of info on Module Federation on internet.
Otherwise here is a link to a concrete implementation by its initial creator: https://github.com/module-federation/module-federation-examples/tree/master/redux-reducer-injection but I don't (or didn't) want to inject my store as a prop.
I think I'll go with this implementation though so feel free to close this issue if you feel like it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants