Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting "Warning: Invalid hook call." when using locally in App due to double React #302

Open
jnachtigall opened this issue Nov 29, 2022 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@jnachtigall
Copy link

Describe the bug
I use the library locally so I can make a few changes. This way I hit this error: https://stackoverflow.com/questions/56021112/react-hooks-in-react-library-giving-invalid-hook-call-error/57422196

The package.json has

"peerDependencies": {
"react": "^18.1.0",
"react-dom": "^18.1.0"

and the rollup config has
PeerDepsExternalPlugin(),

The problem is that the package.json also has these dependencies too:

"react": "^18.2.0",
"react-dom": "^18.2.0",

These last lines should be deleted and only peerDependencies used.

BTW:
There is also

"react-is": "^18.2.0",

But react-is does not seem to be used anywhere.

@prabhuignoto
Copy link
Owner

@jnachtigall Thanks for reporting the issue. can you share the repo details where this issue can be reproduced.

@jnachtigall
Copy link
Author

No, the repo is private. But it is easy to reproduce:

  1. Create a CRA next to your react-chrono folder
  2. In this CRA install react-chrono from you local folder with:
    npm install ../react-chrono/
  3. Use this react-chrono in your CRA project. Then you'll hit the above error.

@prabhuignoto
Copy link
Owner

@jnachtigall

These last lines should be deleted and only peerDependencies used.

devDependencies cannot be modified as react and react-dom are important dependencies for development.

Are you trying to contribute back to the project or you want to customize and use it back in your project. If its for the later reason, then its ideal to make changes on the main repo first.

@prabhuignoto prabhuignoto self-assigned this Dec 4, 2022
@prabhuignoto prabhuignoto added the question Further information is requested label Dec 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants