Skip to content

Possible bug when used with React-Redux v7 #76

Closed
@markerikson

Description

@markerikson

redux-dynamic-modules-react currently has this chunk of code:

https://github.com/Microsoft/redux-dynamic-modules/blob/8d9bbbbb037abeae2b3f4f62345668097c0f8015/packages/redux-dynamic-modules-react/src/DynamicModuleLoader.tsx#L141-L150

This was related to a bug that popped up in React-Redux v7 beta 0, at reduxjs/react-redux#1219 .

Looking at the code further, I can see that you're rendering a <ReactReduxContext.Provider> with your own value. By doing that, you're actually going to completely override the context value from React-Redux itself. That context value normally looks like {store, subscription] in v7. Based on your code, the subscription value will be lost, and nested connected components will not be updated in the correct sequence, and will not take advantage of React's batched updates.

I'd suggest changing this chunk to render both a <ReactReduxContext.Consumer> and a <ReactReduxContext.Provider>, pass down a context value that looks like {store, storeState, subscription}, and memoize producing that value so that it doesn't keep changing on every render (to avoid unnecessary context-caused updates).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions