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 17 support #7695

Closed
Thibaut-Fatus opened this issue Nov 20, 2020 · 5 comments
Closed

React 17 support #7695

Thibaut-Fatus opened this issue Nov 20, 2020 · 5 comments

Comments

@Thibaut-Fatus
Copy link

Version

Test Case

https://codesandbox.io/s/react-router-forked-zeizl?file=/index.js
which does actually work, but the exact same example does not locally

Steps to reproduce

  • yarn install these packages
  • try to use any hooks from react-router-dom (for instance useParams)

you'll get an error Invalid hook call

because [email protected] is resolved and installed in node_modules/react-router-dom/node_modules instead of using the root [email protected]

  • deleting the directory node_modules/react-router-dom/node_modules/react

or

  • adding an alias key in react-script webpack.config like so react: path.resolve('node_modules/react'),

solves the issue

Expected Behavior

react-router-dom has

  "peerDependencies": {
    "react": ">=15"
  },

which should allow [email protected] resolution ?

Actual Behavior

We should be able to use react-router-dom hook useParams without having invalid hook call with react 17

@Thibaut-Fatus
Copy link
Author

Thibaut-Fatus commented Nov 22, 2020

requesting [email protected] in the host package.json fixes the issue since react-router does not install a duplicate version then, but it would be nice to be able to use react 17

@timdorr
Copy link
Member

timdorr commented Nov 23, 2020

Yeah, there's nothing preventing you from installing React 17 and using that. I've got it in place in our production app right now and it works A-OK.

Something is wrong with your installation tooling if it's resolving a different version of React. Router shouldn't have it's own React module under any version of React, as many of the internal instances React uses are going to mismatch and cause issues.

@timdorr timdorr closed this as completed Nov 23, 2020
@mateja176
Copy link

Yeah, there's nothing preventing you from installing React 17 and using that. I've got it in place in our production app right now and it works A-OK.

Something is wrong with your installation tooling if it's resolving a different version of React. Router shouldn't have it's own React module under any version of React, as many of the internal instances React uses are going to mismatch and cause issues.

I've encountered the same problem while using yarn and it may very well be an issue with yarn since react-router specifies

  "peerDependencies": {
    "react": ">=15"
  },

Which does not exclude v17.

justin-hackin added a commit to justin-hackin/svg-widgets-monorepo that referenced this issue Mar 17, 2021
This issue suggested that was the source of problem remix-run/react-router#7695
@alippai
Copy link

alippai commented Jun 22, 2021

It works, but duplicate "react-is" module versions are loaded and bundled, both v16 and v17 (correctly as this is what the react-router specifies in it's package.json). I don't see how the current package.json would allow react v17 (this is true for both v5 and v6)

@bezsinnyidmytro
Copy link

does it have any solution to leave host app with react v17 and not have 2 versions of react in the bundle?
I still see that both 16 and 17 is added to package-lock

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

5 participants