Commit 8865b2f
authored
Fix: Auth0-Lock Error with React 19 and Nextjs 15 (#2701)
### Changes
Fixes React 19 and NextJS 15 compatibility issues in auth0-lock by
removing deprecated APIs that were removed in React 19:
- Legacy string refs (`ref="name"`)
- `ReactDOM.findDOMNode()`
- `react-transition-group` v2 (which used deprecated APIs)
**Root Cause:** auth0-lock was using legacy string refs (e.g.,
`ref="chrome"`) which were removed in React 19
- Closes #[2590](#2590)
### Changes Made
#### 1. String Refs → React.createRef() (13 files)
Converted all legacy string refs to the modern `createRef()` pattern:
**Before (React 18 and earlier):**
```
<Chrome ref="chrome" />
this.refs.chrome.focusError()
```
After (React 19 compatible):
```
constructor(props) {
super(props);
this.chromeRef = React.createRef();
}
<Chrome ref={this.chromeRef} />
this.chromeRef.current.focusError()
```
2. Removed `ReactDOM.findDOMNode()`
Replaced all `ReactDOM.findDOMNode()` calls with direct ref access:
Before:
```
const node = ReactDOM.findDOMNode(this);
node.focus();
```
After:
```
const node = this.nodeRef.current;
node.focus();
```
3. Added nodeRef Props to CSSTransition
Added nodeRef props to CSSTransition components to avoid
react-transition-group's findDOMNode fallback:
Before:
```
<CSSTransition classNames="slide" timeout={350}>
{children}
</CSSTransition>
```
After:
```
<CSSTransition
nodeRef={this.transitionRef}
classNames="slide"
timeout={350}
>
<div ref={this.transitionRef}>
{children}
</div>
</CSSTransition>
```
4. Dependency Upgrades
- react-transition-group: 2.2.1 → 4.4.5 (v2 used deprecated React APIs)
### Testing
Test Environment:
- Next.js 15.2.6
- React 19.2.1
- React DOM 19.2.1
#### Test Scenarios:
- Lock widget renders without errors
- No "Expected ref to be a function" errors
- No "findDOMNode is not a function" errors
- No legacy context API warnings
- Widget interactions work (typing, tab switching, form submission)
* [ ] This change adds unit test coverage
* [ ] This change adds integration test coverage
* [ ] This change has been tested on the latest version of the
platform/language
### Checklist
* [x] I have read the [Auth0 general contribution
guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
* [x] I have read the [Auth0 Code of
Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)
* [x] All code quality tools/guidelines have been run/followed
* [ ] All relevant assets have been compiled1 parent b3f3681 commit 8865b2f
File tree
16 files changed
+114
-84
lines changed- src
- __tests__
- ui
- box
- input
16 files changed
+114
-84
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
| 134 | + | |
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
64 | 67 | | |
65 | 68 | | |
66 | 69 | | |
| |||
0 commit comments