-
Notifications
You must be signed in to change notification settings - Fork 29.3k
Description
Bug report
Describe the bug
next
v10.0.0 forces react
v17 to be installed, even if the project has react
v16 in dependencies.
This is because next
v10.0.0 has a use-subscription
v1.5.0 dependency pinned:
next.js/packages/next/package.json
Line 117 in 118ab79
"use-subscription": "1.5.0", |
use-subscription
v1.5.0 has a react
peer dependency of ^17.0.0
(v16 not supported):
https://unpkg.com/[email protected]/package.json
With a project that has a react
v16 dependency, npm v6 at install time would emit a warning that the use-subscription
peer dependency on react
is not satisfied, but it would not install react
v17. While this may seem ok, it probably is not because use-subscription
declared react
v16 is not supported, so who knows if it will have problems in it's function.
With npm v7, which automatically installs peer dependencies as needed, this results in react
v16 being installed to fulfill the project dependency, and react
v17 to fulfill the use-subscription
peer dependency. The result is that multiple versions of react
get installed, and this can cause a React render error that multiple instances of React are being used with hooks.
To Reproduce
- In a hello-world Next.js project, ensure React v16 is specified in the package dependencies.
- Use npm v7 to install the project.
- Run
npm ls react
to see the multiple versions installed. This in itself is bad. - At this point, you could try to run
npm run dev
to see if you get the same React render error I do in my project about hooks and multiple React instances, but I'm not 100% sure if it will happen out of the box or if you need to use some particular hooks to see the issue.
Expected behavior
When used with npm v6 or v7, next
should respect the version of react
installed in the user's project, and not cause multiple versions of react
to be installed.
Screenshots
System information
- OS: macOS 10.15.7
- Version of Next.js: 10.0.0
- Version of Node.js: Any compatible with npm v6, v7
- Version of npm: v7 especially