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 should be a peer dependency, not a dependency #155

Open
tstirrat15 opened this issue Apr 24, 2019 · 9 comments
Open

React should be a peer dependency, not a dependency #155

tstirrat15 opened this issue Apr 24, 2019 · 9 comments

Comments

@tstirrat15
Copy link
Contributor

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.

@tstirrat15
Copy link
Contributor Author

@samkelleher
Copy link

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

@MYKEU
Copy link

MYKEU commented Aug 15, 2019

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 #156 be merged any time soon?

@eseQ
Copy link

eseQ commented Nov 14, 2019

Any updates?

@samkelleher
Copy link

Workaround

This error will happen after updating the version of React used in your application.

  1. Delete node_modules
  2. Delete yarn.lock
  3. Run yarn
  4. Verify by running 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.

@dommangetnicolas
Copy link

The workaround didn't work for me. Are there any updates?

@tstirrat15
Copy link
Contributor Author

Nope. Check out the fork if you're still having problems. This library is pretty much dead.

@scruffian
Copy link

Check out the fork if you're still having problems. This library is pretty much dead.

Which fork?

@tstirrat15
Copy link
Contributor Author

It might have been this one? It's been long enough since I've touched this that I don't remember.

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

Successfully merging a pull request may close this issue.

6 participants