Open tstirrat15 opened 5 years ago
More reading here: https://yarnpkg.com/blog/2018/04/18/dependencies-done-right/
I was brought here because after installing Webpack plugin duplicate-package-checker-webpack-plugin
, I can see that the style loader is pulling in it's own version of React.
WARNING in react
Multiple versions of react found:
16.8.4 ./~/isomorphic-style-loader/~/react
16.8.6 ./~/react
I just updated from react: 16.8.6
to react: 16.9.0
and I am now seeing the error due to using useStyle
hook:
Error: Invariant Violation: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the followi ng reasons:
1. You might have mismatching versions of React and the renderer (such as Reac t DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
Will https://github.com/kriasoft/isomorphic-style-loader/pull/156 be merged any time soon?
Any updates?
This error will happen after updating the version of React used in your application.
node_modules
yarn.lock
yarn
yarn why react
and seeing that only one version is referenced.Your application will now run normally. All the versions of React are now consistent in your application.
The workaround didn't work for me. Are there any updates?
Nope. Check out the fork if you're still having problems. This library is pretty much dead.
Check out the fork if you're still having problems. This library is pretty much dead.
Which fork?
It might have been this one? It's been long enough since I've touched this that I don't remember.
This package only works in the context of a React application, but it doesn't require its own version of React.
Additionally, with recent changes to React's APIs (context, hooks), having multiple versions of React in an application can cause errors.
Moving React from a dependency to a peerDependency will address this.