Skip to content

React-Redux bad usage of peerDependencies #1846

Closed
@jmfrancois

Description

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/react-redux@7.2.6/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/react-redux@7.2.6/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

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