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
Support React-Redux V6 #27
Comments
@winklerp Thanks I'll take a look |
@winklerp Here, I think we can use the ReactReduxContext.Consumer that is exposed, and get the same behavior |
Hi, ReactReduxContext.Consumer works. But since React-Redux 6 supports custom context I think we should pass the context into DynamicModuleLoader and not only rely hard coded on ReactReduxContext. See release notes of react redux 6.0-beta: • Passing store as a prop to a connected component is no longer supported. Instead, you may pass a custom context={MyContext} prop to both and . You may also pass {context : MyContext} as an option to connect. With this it is possible to have several stores in different contexts. So this is why I think passing the context to module loader is necessary. By the way: if we pass a property named store, react redux throws an exception :). Only passing the context works. |
It's released now. |
Is it ok that I get undefined when I try to access dynamic modules's state ("myModule") when I wrap Lazy component with connect function and use it inside DynamicModuleLoader component? Is't it supposed to have "myModule" to be loaded? |
@navneet-g Could you chime in here? I am able to reproduce the problem reported above, but I am not sure why. I see that the ReactRedux provider context passes store (which has the correct state) and storeState (which does not) |
@abdurahmanus This is really interesting ... I spent sometime in debugging but did not reach a conclusion, so far it is pointing in direction that it is outside scope of redux dynamic modules and something related to react and react-redux. For example see below screenshot, the _this2.setState actually calls mapStateToProps twice first with old state that does not have myModule state set and immediately after correct state. |
@navneet-g it seems like this behavior was changed somewhere in between v5.1.1 and 6.0.0 of react-redux. |
If this is a behavior change in react-redux, please open an issue there, we can take it forward then depending upon if they make changes. |
I did further debugging and opened following issue in react-redux repo |
This is due to a known change in react-redux with their support to new context API. We need to update DynamicModuleLoader as follows https://codesandbox.io/s/pwmm8r3110 |
React-Redux v6 will use React's ( new ) context api which is not compatible with the legacy context API. By accessing store from context ( reference ) it causes the app to break when it tries to dynamic load modules.
"Could not load store from React context" - Error is thrown in DynamicModuleLoader.
As @timdoor has described in its breaking changes:
Passing store as a prop to a connected component is no longer supported. Instead, you may pass a custom context={MyContext} prop to both and . You may also pass {context : MyContext} as an option to connect.
The text was updated successfully, but these errors were encountered: