Skip to content

Commit

Permalink
Devtools: Ensure component control flow is consistent with commit whe…
Browse files Browse the repository at this point in the history
…n using `useDeferredValue`
  • Loading branch information
Sebastian Silbermann committed Mar 6, 2024
1 parent 24a37de commit 4974448
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/react-debug-tools/src/ReactDebugHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,14 +461,15 @@ function useTransition(): [

function useDeferredValue<T>(value: T, initialValue?: T): T {
const hook = nextHook();
const prevValue = hook !== null ? hook.memoizedState : value;
hookLog.push({
displayName: null,
primitive: 'DeferredValue',
stackError: new Error(),
value: hook !== null ? hook.memoizedState : value,
value: prevValue,
debugInfo: null,
});
return value;
return prevValue;
}

function useId(): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,20 @@ describe('ReactHooksInspectionIntegration', () => {
"subHooks": [],
"value": false,
},
{
"debugInfo": null,
"hookSource": {
"columnNumber": 0,
"fileName": "**",
"functionName": "Foo",
"lineNumber": 0,
},
"id": null,
"isStateEditable": false,
"name": "Context",
"subHooks": [],
"value": "provided",
},
{
"debugInfo": null,
"hookSource": {
Expand Down

0 comments on commit 4974448

Please sign in to comment.