question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't use a npm library, which depends on react-redux, on different library versions among repositories

See original GitHub issue

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

003

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.

002 01

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:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
phryneascommented, Aug 29, 2022

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.

2reactions
markeriksoncommented, Aug 29, 2022

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 separate ReactReduxContext instances, React sees them as being !==, and they are treated as being different and things don’t line up right.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found