kriasoft / isomorphic-style-loader

CSS style loader for Webpack that is optimized for isomorphic (universal) web apps.
https://reactstarter.com
MIT License
1.27k stars 144 forks source link

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

Open tstirrat15 opened 5 years ago

tstirrat15 commented 5 years ago

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 commented 5 years ago

More reading here: https://yarnpkg.com/blog/2018/04/18/dependencies-done-right/

samkelleher commented 5 years ago

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 commented 5 years ago

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?

eseQ commented 4 years ago

Any updates?

samkelleher commented 4 years ago

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 commented 4 years ago

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

tstirrat15 commented 4 years ago

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

scruffian commented 3 years ago

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

Which fork?

tstirrat15 commented 3 years ago

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