prabhuignoto / react-chrono

🕑 Modern Timeline Component for React
https://react-chrono.prabhumurthy.com
MIT License
3.9k stars 208 forks source link

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

Open jnachtigall opened 1 year ago

jnachtigall commented 1 year ago

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 https://github.com/prabhuignoto/react-chrono/blob/9c7bc09b71bbc4935a0d3eb703bb066e192b74f0/package.json#L39-L41 and the rollup config has https://github.com/prabhuignoto/react-chrono/blob/9c7bc09b71bbc4935a0d3eb703bb066e192b74f0/rollup.config.mjs#L54

The problem is that the package.json also has these dependencies too: https://github.com/prabhuignoto/react-chrono/blob/9c7bc09b71bbc4935a0d3eb703bb066e192b74f0/package.json#L94-L95

These last lines should be deleted and only peerDependencies used.

BTW: There is also https://github.com/prabhuignoto/react-chrono/blob/9c7bc09b71bbc4935a0d3eb703bb066e192b74f0/package.json#L96

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

prabhuignoto commented 1 year ago

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

jnachtigall commented 1 year ago

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 commented 1 year ago

@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.