Skip to content

Remove dependency on "react-dom" #39

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

Closed

Conversation

saviocmc
Copy link
Contributor

Fixes get-convex/convex-backend#74

Currently, the react client depends directly on the react-dom package, specifically the unstable_batchedUpdates implementation. This makes it impossible to use it on react-native only projects (with no react-dom installed).

react-native also implements this method, but it is obsolete since the react 18 release, with the implementation of Automatic batching (explained in more details here).

A fix for this could be to test if the client is running react 17 and try o import unstable_batchedUpdates from either react-dom or react-native, but as discussed in the issue, a simpler solution could be to drop react 17 support, removing the need to use unstable_batchedUpdates.

This PR introduces these changes:

  • Remove react-dom from the peer dependencies
  • Remove version 17 as a valid peer dependency for react
  • Remove the use the unstable_batchedUpdates in the react client transition method.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link
Collaborator

@thomasballinger thomasballinger left a comment

Choose a reason for hiding this comment

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

Looks good, I didn't realize how little we needed this

@saviocmc saviocmc force-pushed the remove-dependency-on-react-dom branch from 99604b8 to 3efd229 Compare April 29, 2025 19:08
@saviocmc
Copy link
Contributor Author

Looks good, I didn't realize how little we needed this

The only place I could find the react-dom referenced in the codebase was the unstable_batchedUpdates call, so it is safe to remove on react ^18 and ^19.

Testing further, I just added react-dom again in devDependencies only because it is a peer dependency of @auth0/auth0-react (that is a dev dependency of the convex package) in order to fix package resolution, but it should not impact anything.

@thomasballinger
Copy link
Collaborator

thanks, yeah I did the same. Thank you @saviocmc! This is in ab06d42, and will be announced in the next release. I'll do one soon, likely this week.

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.

Convex React client requires "react-dom" to be installed even on react-native only projects
2 participants