Skip to content

Commit

Permalink
Backport useId tracking fix to React 18
Browse files Browse the repository at this point in the history
A hydration error occurs when using `useId` with a parent that has a render phase update. This has already been fixed in React 19 by facebook#25713.

React 18 will have users for some time, and this issue is showing up in production. Therefore, this backports that fix to React 18.

Fixes facebook#31653.
  • Loading branch information
kognise committed Dec 4, 2024
1 parent f1338f8 commit babdf2e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
1 change: 0 additions & 1 deletion packages/react-reconciler/src/ReactFiberHooks.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,6 @@ export function renderWithHooks<Props, SecondArg>(
let numberOfReRenders: number = 0;
do {
didScheduleRenderPhaseUpdateDuringThisPass = false;
localIdCounter = 0;

if (numberOfReRenders >= RE_RENDER_LIMIT) {
throw new Error(
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberHooks.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ export function renderWithHooks<Props, SecondArg>(
let numberOfReRenders: number = 0;
do {
didScheduleRenderPhaseUpdateDuringThisPass = false;
localIdCounter = 0;
// localIdCounter = 0;

if (numberOfReRenders >= RE_RENDER_LIMIT) {
throw new Error(
Expand Down

0 comments on commit babdf2e

Please sign in to comment.