Skip to content
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

React-Redux bad usage of peerDependencies #1846

Closed
1 task
jmfrancois opened this issue Dec 1, 2021 · 2 comments
Closed
1 task

React-Redux bad usage of peerDependencies #1846

jmfrancois opened this issue Dec 1, 2021 · 2 comments

Comments

@jmfrancois
Copy link

What version of React, ReactDOM/React Native, Redux, and React Redux are you using?

  • React: 16.14.0
  • ReactDOM/React Native: 16.14.0
  • Redux: 4.1.2
  • React Redux: 7.2.6

What is the current behavior?

while installing react-redux without react-dom make the usage of the UMD impossible.
The UMD needs react-dom aka ReactDOM global setup.
Our build toolchain leverage the peerDependencies field of the package.json of react-redux and because it is badly setup it do not see the dependencies between both.

In the end we have :

Uncaught TypeError: reactDom is undefined

because our toolchain place reactdom script tag way after react-redux.
Looking at the code inside the UMD shows you have to provide react-dom to make it work.

https://unpkg.com/browse/[email protected]/dist/react-redux.js

  setBatch(reactDom.unstable_batchedUpdates);

there is not conditional on reactDom is here.

peerDependencies

Reading official docs https://docs.npmjs.com/cli/v8/configuring-npm/package-json#peerdependenciesmeta show peerDependenciesMeta field should be used for declared peerDependencies.

https://unpkg.com/browse/[email protected]/package.json
We can see react-dom is only in peerDependenciesMeta.

What is the expected behavior?

Please add react-dom and react-native as peerDependencies in the package.json 🙏
It would let the user choose between both and our toolchain able to understand react-dom is a peerDependencies.

I will be able to push the PR later on this week I think.

Which browser and OS are affected by this issue?

all

Did this work in previous versions of React Redux?

  • Yes
@timdorr
Copy link
Member

timdorr commented Dec 1, 2021

We've had a bunch of discussions on this:

The main result is we can't put them into peerDeps yet because many people still use older versions of npm (or other installers) that don't support peerDepsMeta and cause lots of warnings for them. This is the best solution for now.

@timdorr timdorr closed this as completed Dec 1, 2021
@markerikson
Copy link
Contributor

That said, it helps to know that you are using the UMD build. I'd been debating whether to remove that in React-Redux v8.

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

No branches or pull requests

3 participants