kriasoft / isomorphic-style-loader

CSS style loader for Webpack that is optimized for isomorphic (universal) web apps.

Home Page:https://reactstarter.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

React should be a peer dependency, not a dependency

tstirrat15 opened this issue · comments

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.

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

Any updates?

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.

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.