Skip to content

Fix DynamicModuleLoader and remove support for React-Redux 5 #77

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

Merged
merged 6 commits into from
May 9, 2019

Conversation

abettadapur
Copy link
Collaborator

@abettadapur abettadapur commented Apr 7, 2019

This PR fixes:

  • Possible bug when used with React-Redux v7 #76: We were not applying ALL of the context values that were provided from ReactReduxContext, so do that here.
  • When using the createStore prop, we were not providing a modified context to the first connected component. Now, if we call createStore and render a Provider, we will render another instance of DynamicModuleLoader, which will actually add the modules.
  • While writing this PR, I also decided to simplify the component by removing support for react-redux@5

This should result in a major version bump to V4

if (this.props.reactReduxContext !== this._memoizedRRContext) {
this._memoizedRRContext = {
...this.props.reactReduxContext,
storeState: this.props.reactReduxContext.store.getState(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we memoizing state only when context changes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the state changes above, then we will get a new context object here.

See: https://github.com/reduxjs/react-redux/blob/162b81a3fffe75ff6181b711777067ba6e63a34b/src/components/Provider.js#L59

this.setState({...}) returns a new object

@navneet-g
Copy link
Contributor

Please add some unit tests ... did you test all the examples with these changes?


createStore?: () => IModuleStore<any>;
interface IDynamicModuleLoaderImplProps extends IDynamicModuleLoaderProps {
reactReduxContext?: { store: IModuleStore<any> };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc comments.

throw new Error(
"Store could not be resolved from React context"
public render(): React.ReactNode {
if (this.state.readyToRender) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comments?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What comments are you looking for here? This seems pretty self explanatory to me

@abettadapur abettadapur merged commit e3b0d55 into master May 9, 2019
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

Successfully merging this pull request may close these issues.

2 participants