Skip to content

fix: Move react and react-dom from dependencies to peerDependencies#1024

Merged
DafyddLlyr merged 2 commits into
mainfrom
dp/match-react-versions-planx-new
Jul 5, 2026
Merged

fix: Move react and react-dom from dependencies to peerDependencies#1024
DafyddLlyr merged 2 commits into
mainfrom
dp/match-react-versions-planx-new

Conversation

@DafyddLlyr

@DafyddLlyr DafyddLlyr commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What's the problem?

planx-core renders React e.g. generateApplicationHTML()), but has react and react-dom declared as regular dependencies. That makes planx-core bundle its own copy of React. When a consuming app resolves React to even a slightly different patch version, two copies end up in the dependency tree (verified with pnpm why react in planx-new).

Downstream in the API this this surfaced as a crash during HTML generation -

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
See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.

What's the solution?

From the docs -

If you see more than one React, you’ll need to figure out why this happens and fix your dependency tree. For example, maybe a library you’re using incorrectly specifies react as a dependency (rather than a peer dependency).

  • Move react and react-dom to peerDependencies so planx-new will dedupe onto it's React copy
  • Add react and react-dom to devDependencies so planx-core still builds and can be tested locally

@DafyddLlyr DafyddLlyr requested a review from a team July 3, 2026 16:10
@DafyddLlyr DafyddLlyr changed the title chore: Match react versions to planx-new fix: Move react and react-dom from dependencies to peerDependencies Jul 3, 2026

@freemvmt freemvmt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix

@jessicamcinchak jessicamcinchak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Helpful explanation, thanks for fixing ! Do we expect MUI to hit same issue?

@DafyddLlyr

Copy link
Copy Markdown
Contributor Author

Do we expect MUI to hit same issue?

Great question - hadn't considered that. I expect the same fix would be wise here - let me read up and I'll open another PR to confirm this.

@DafyddLlyr DafyddLlyr merged commit e073c2f into main Jul 5, 2026
4 checks passed
@DafyddLlyr DafyddLlyr deleted the dp/match-react-versions-planx-new branch July 5, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants