'A react app inside a monorepo (lerna) package causing conflicting 'react' package

I created :

  • A reusable react component package, and
  • A react app for testing the component

Both of them are inside a monorepo (lerna). The problem is the "react" packages for the component & for the app are pointed to "different thing", thus using hook inside the component triggers this error: "Hooks can only be called inside the body of a function component".

Deleting the second "react" package directory will affect to the component project because it's a symbolic linking (similar to shortcut to component project). Any idea for resolving my problem?enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source