Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React should be a peer dependencies

See original GitHub issue

One think I noticed working on the AtlasMap POC is that I was getting the Invalid Hook Call Warning error in the console. Ultimately, it was due to @kogito/core-api declaring React as direct dependency, which causes for multiple versions of React being embedded in the bundle. Since AtlasMap is written solely using hooks, this issue come up immediately.

A quick workaround was to instruct WebPack to consider React an external dependency, but it would be better to make React and React DOM peer dependencies in the core-api package.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11

github_iconTop GitHub Comments

riccardo-forinacommented, Jun 22, 2020

I mean, your project your rules 😄

Let’s say that this would be quite an exception in the npm ecosystem and would limit peers to use the provided template and tools (what if I don’t want to use webpack? Sure things like rollup allow for declaring external global dependencies, but I don’t see why adding this cognitive burden to users).

riccardo-forinacommented, Jul 10, 2020

Yup I think I’m with you. If I may, check out tsdx as a library boilerplate generator. It uses rollup under the hood that’s more suited to create libraries than webpack and makes working with this stuff easier.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding Peer Dependencies in JavaScript
In this case, you would declare React as a peer dependency for your components, because you want the host project to have the...
Read more >
What is the correct way of adding a dependency to react in ...
peerDependencies specifies which version(s) of React your reusable component supports/requires. When using npm 2 this also adds React to the ...
Read more >
Why use peer dependencies?
A library will often specify a peer dependency when it wants a dependency to be ... and @mdx-js/react ) are peer dependencies of...
Read more >
npm Peer Dependencies - Fathom
For example, if you are building a library of React components, React will be a dependency you need, but almost certainly the application...
Read more >
React should be a peer dependency · Issue #1389
Peer dependencies can have minimum versions, the problem is normal dependencies cause a duplicate version of the library to be baked in. This ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found