Can't use a npm library, which depends on react-redux, on different library versions among repositories
See original GitHub issueWhat version of React, ReactDOM/React Native, Redux, and React Redux are you using?
The versions
"react": "17.0.2"
"react-dom": "17.0.2"
"redux": "4.2.0"
"react-redux": "8.0.2"
What is the current behavior?
Context
I’m working on a multi-frontend environment with Webpack
module federation + react
+ redux
+ a NPM library for shared components, which uses react-redux
to compose the shared store.
The issue
All repositories (aka micro-frontends - MFE), must use the SAME SDK library version. When we don’t, react-redux
breaks weirdly. Even when publishing two versions with the same code, it doesn’t run.
What is the expected behavior?
It should work properly since there wasn’t code changes, only the package version is different.
Which browser and OS are affected by this issue?
Chrome 104
Did this work in previous versions of React Redux?
- Yes
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Store not passed via Provider to imported components in ...
The bug manifests itself if react-redux version 6 is used in a NPM module that exports some connected React component. The NPM module...
Read more >How to satisfy libraries that depend on different versions of ...
Hi guys I have a problem with NPM dependencies. It turns out that in my project, I'm using React version 17.0.2 but I...
Read more >How I Estimate NPM Package Market Share (and how Redux ...
This is a post in the Blogged Answers series. Techniques and sources I use to estimate relative market share of various NPM packages, ......
Read more >Deploy React Component As An NPM Library - codeburst
The challenge here is how do we write and publish a module dependent on a JS framework to be used as an NPM...
Read more >react-redux - npm
You'll also need to install Redux and set up a Redux store in your app. This assumes that you're using npm package manager...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, because if you have two different versions of the library bundled up in your code (and that’s what is probably happening), they won’t be able to see each other. You might be using the Provider from one version with the useContext call from the other.
Yeah, what’s probably happening is that each distinct build of your own app’s base package is bundling in a copy of React-Redux. Thus, when the app loads, there are multiple copies of React-Redux, each with its own entirely separate
const ReactReduxContext = React.createContext()
call inside. Thus, there are totally separateReactReduxContext
instances, React sees them as being!==
, and they are treated as being different and things don’t line up right.