Comments (12)
@winklerp Thanks I'll take a look
from redux-dynamic-modules.
@winklerp Here, I think we can use the ReactReduxContext.Consumer that is exposed, and get the same behavior
from redux-dynamic-modules.
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.
from redux-dynamic-modules.
It's released now.
from redux-dynamic-modules.
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?
https://codesandbox.io/s/7200w810n6
from redux-dynamic-modules.
@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)
from redux-dynamic-modules.
@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.
from redux-dynamic-modules.
@navneet-g it seems like this behavior was changed somewhere in between v5.1.1 and 6.0.0 of react-redux.
the same example with react-redux v5.1.1 works different way (no undefined value)
https://codesandbox.io/s/xj6l40kjqw
The question is what should be considered as correct behavior? If (while loading process) some module could be undefined it should have nullable type in *AwareState interface (if ts using) and should be checked for undefined value in mapStateToProps or anywere else.
from redux-dynamic-modules.
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.
from redux-dynamic-modules.
I've also noticed that todo-example uses react-redux@6 and it's broken now
from redux-dynamic-modules.
I did further debugging and opened following issue in react-redux repo
reduxjs/react-redux#1194
from redux-dynamic-modules.
This is due to a known change in react-redux with their support to new context API.
reduxjs/react-redux#1126
We need to update DynamicModuleLoader as follows https://codesandbox.io/s/pwmm8r3110
I probably won't have time, if someone wants to make change and send the PR, it would be awesome.
from redux-dynamic-modules.
Related Issues (20)
- Is it possible to shave off React+ dependencies? HOT 1
- Could it be possible to provide simple Lit Element (Web Components) example
- support for nested reducers HOT 4
- Typing initialActions function
- [Examples] There is no 'enhancements' property
- [Examples] Unused argument 'getState'
- State and reducers are not removed when dynamic component unmounts HOT 2
- PENDING action is gone from sagas HOT 6
- remain module when component unmount HOT 2
- State lost, when moving from one module to another module HOT 1
- Remove module by id HOT 1
- modules are removed before useEffect cleanups are executed
- Update with React 16.x or 17.x
- takexxx saga(saga watched action) in different modules that have been loaded doesn't work in dynamic modules HOT 1
- Build pipeline failing for main
- Library abandoned? HOT 2
- TypeScript React: incorrect children props HOT 3
- This repo is missing important files HOT 3
- Module '"redux-dynamic-modules"' has no exported member 'IModule'.
- Any way to use the redux-toolkit with this lib? I have a code sample in the description..
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redux-dynamic-modules.