Fix: React 19 compatibility - move react, react-dom, and react-transition-group to peerDependencies#2743
Open
ankita10119 wants to merge 1 commit intomasterfrom
Open
Fix: React 19 compatibility - move react, react-dom, and react-transition-group to peerDependencies#2743ankita10119 wants to merge 1 commit intomasterfrom
ankita10119 wants to merge 1 commit intomasterfrom
Conversation
…tion-group to peerDependencies
Piyush-85
approved these changes
Mar 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Problem
Users running
auth0-lockin a React 19 project encounter the following error immediately onlock.show(), preventing the Lock widget from rendering:Uncaught Error: Objects are not valid as a React child
Reported in: #2739
Root Cause
react,react-dom, andreact-transition-groupwere declared as regular dependencies inpackage.json. This caused npm to install Lock's own copy of React 18.3.1 insideauth0-lock/node_modules, separate from the consuming app's React version.In Vite-based projects (and similar bundlers that don't deduplicate modules across symlinked packages), this results in two React instances existing simultaneously:
react-transition-groupresolves to the app's React 19 (via Vite's module deduplication)mapIntoArray(inside React.Children.map) receives elements created by React 18, elements with a different internal structure (ref as a top-level key in React 18 vs inside props in React 19)This is the classic "multiple React instances" problem. The fix is to declare React as a peerDependency so Lock always uses the consuming app's React instance.
Fix
Moved
react,react-dom, andreact-transition-groupfrom dependencies to peerDependencies:Added them to devDependencies so the local build, tests, and development workflow continue to work unchanged.
This is the standard pattern for React component libraries, React should never be bundled as a private dependency.
References
Closes #2739
Testing
auth0-lock@14.2.4(published) +React 19.2.4in a Vite app, Objects are not valid as a React child error appeared immediately onlock.show()Concerns & Answers
Q: Will this break users who use Lock via CDN / standalone bundle?
No. The CDN build (
lock.min.js) is a self-contained webpack bundle that includes all dependencies bundled into a single file. peerDependencies only affect npm package consumers and have no impact on the CDN bundle.Q: Will this break users using Lock via npm in a non-React project (vanilla JS, Vue, Angular, etc.)?
These users will now need to explicitly install
react,react-dom, andreact-transition-groupas dependencies in their own project. Before this fix, these were being installed silently as transitive dependencies. Lock has always been a React-based widget internally, React was always required at runtime. The change makes this requirement explicit rather than hidden. npm will warn users about missing peerDependencies if they haven't installed them.For non-React projects, using Lock via the CDN bundle is the simpler option and remains unaffected.
Q: Does this affect React 16, 17, or 18 users?
No. The peerDependencies range is
>=16.8.0, so all supported React versions continue to work. The only change is that Lock no longer silently installs its own private React copy, it uses whichever version the consuming app has installed.Q: Why was react-transition-group also moved to peerDependencies?
react-transition-groupitself hasreactandreact-domas peerDependencies. If it resolves to a different React instance than the one Lock is using, the same mismatch problem can occur.Moving it to peerDependencies ensures it always uses the same React instance as the consuming app and Lock.
Checklist