GeezerVison is showing github.com — Warn if static flag is accidentally cleared (#20807) · react/react@696e736
File tree
Expand file treeCollapse file tree
Open diff view settings
packages/react-reconciler/src
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberHooks.new.js +15Lines changed: 15 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -471,6 +471,21 @@ export function renderWithHooks<Props, SecondArg>( |
471 | 471 | currentHookNameInDev = null; |
472 | 472 | hookTypesDev = null; |
473 | 473 | hookTypesUpdateIndexDev = -1; |
| 474 | + |
| 475 | + // Confirm that a static flag was not added or removed since the last |
| 476 | + // render. If this fires, it suggests that we incorrectly reset the static |
| 477 | + // flags in some other part of the codebase. This has happened before, for |
| 478 | + // example, in the SuspenseList implementation. |
| 479 | + if ( |
| 480 | + current !== null && |
| 481 | + (current.flags & PassiveStaticEffect) !== |
| 482 | + (workInProgress.flags & PassiveStaticEffect) |
| 483 | + ) { |
| 484 | + console.error( |
| 485 | + 'Internal React error: Expected static flag was missing. Please ' + |
| 486 | + 'notify the React team.', |
| 487 | + ); |
| 488 | + } |
474 | 489 | } |
475 | 490 |
|
476 | 491 | didScheduleRenderPhaseUpdate = false; |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberHooks.old.js +15Lines changed: 15 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -471,6 +471,21 @@ export function renderWithHooks<Props, SecondArg>( |
471 | 471 | currentHookNameInDev = null; |
472 | 472 | hookTypesDev = null; |
473 | 473 | hookTypesUpdateIndexDev = -1; |
| 474 | + |
| 475 | + // Confirm that a static flag was not added or removed since the last |
| 476 | + // render. If this fires, it suggests that we incorrectly reset the static |
| 477 | + // flags in some other part of the codebase. This has happened before, for |
| 478 | + // example, in the SuspenseList implementation. |
| 479 | + if ( |
| 480 | + current !== null && |
| 481 | + (current.flags & PassiveStaticEffect) !== |
| 482 | + (workInProgress.flags & PassiveStaticEffect) |
| 483 | + ) { |
| 484 | + console.error( |
| 485 | + 'Internal React error: Expected static flag was missing. Please ' + |
| 486 | + 'notify the React team.', |
| 487 | + ); |
| 488 | + } |
474 | 489 | } |
475 | 490 |
|
476 | 491 | didScheduleRenderPhaseUpdate = false; |
|