Skip to content

Yarn Workspaces and reactJS Invalid Hook call #8540

@yehonadav

Description

@yehonadav

Having a lot of trouble trying to set up a common UI library.

I've set up a yarn workspace which looks like this:

/monorepo
   /common-16.13
   /react-app-16.8.
   /another-app-16.13

I then import common-16.13 into react-app-16.8 and use one of the components like this:

 /react-app/home.js
    import {SharedComponent} from "common"

However when I run the application I get this error:

react.development.js?80c6:1465 Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as 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 exporting my common package to a different repo (not using yarn workspace) everything works fine.

more information about my issue can be found here:
https://stackoverflow.com/questions/61263658/yarn-workspaces-and-invalid-hook-call

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions