Giter Site home page Giter Site logo

Comments (12)

abettadapur avatar abettadapur commented on May 21, 2024 1

@winklerp Thanks I'll take a look

from redux-dynamic-modules.

abettadapur avatar abettadapur commented on May 21, 2024

@winklerp Here, I think we can use the ReactReduxContext.Consumer that is exposed, and get the same behavior

from redux-dynamic-modules.

winklerp avatar winklerp commented on May 21, 2024

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.

cschleiden avatar cschleiden commented on May 21, 2024

It's released now.

from redux-dynamic-modules.

abdurahmanus avatar abdurahmanus commented on May 21, 2024

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.

abettadapur avatar abettadapur commented on May 21, 2024

@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.

navneet-g avatar navneet-g commented on May 21, 2024

@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.

image

from redux-dynamic-modules.

abdurahmanus avatar abdurahmanus commented on May 21, 2024

@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.

navneet-g avatar navneet-g commented on May 21, 2024

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.

abdurahmanus avatar abdurahmanus commented on May 21, 2024

I've also noticed that todo-example uses react-redux@6 and it's broken now
image

from redux-dynamic-modules.

navneet-g avatar navneet-g commented on May 21, 2024

I did further debugging and opened following issue in react-redux repo
reduxjs/react-redux#1194

from redux-dynamic-modules.

navneet-g avatar navneet-g commented on May 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.