0

so after publishing package when i import it in local application then it's giving me

There are three common reasons you might be seeing it:

  1. You might have mismatching versions of React and React DOM.
  2. You might be breaking the Rules of Hooks.
  3. You might have more than one copy of React in the same app.

after some googling i have checked with npm ls react command and it show me only 1 version available and i guess that's not an issue in case,hence i have change it to class based component to make it work.

So i would like to know is there any way to implement react hooks in npm module with webpack or any other way if possible ?

Prashant Shah
  • 226
  • 1
  • 8
  • Sorry, could you clarify, do you run ```npm ls react``` in your package for publishing or in the application that uses it? – Anastasiia Solop Sep 28 '20 at 12:02
  • @AnastasiiaSolop, i ran the command npm ls react in my application after importing it. – Prashant Shah Sep 28 '20 at 12:43
  • Very strange, I had a very similar issue with my npm module, but the issue was that react was installed in both my app and the library. React should be declared as a peerDependency in the library and not as a main dependency. Have you checked the other two reasons above? – Anastasiia Solop Sep 28 '20 at 14:02
  • yes i have added react and react-dom as a peerdependency in package and for the other two reason i'm not able to debug it and when i replace hooks with class component it's working, not sure , but is it anything wrong with webpack configuration that i need to do for hooks or need to do configuration for babel ? as per current scenario i'm producing dist folder for package using webpack. – Prashant Shah Sep 30 '20 at 06:49

0 Answers0