Skip to content

Commit e97cda8

Browse files
committed
[Fiber] Avoid duplicate debug info for array children
1 parent df3f012 commit e97cda8

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

packages/react-devtools-shared/src/__tests__/store-test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2857,8 +2857,7 @@ describe('Store', () => {
28572857
expect(store).toMatchInlineSnapshot(`
28582858
[root]
28592859
▾ <App> [Server]
2860-
▾ <App> [Server]
2861-
<ClientComponent key="app">
2860+
<ClientComponent key="app">
28622861
`);
28632862
});
28642863

packages/react-reconciler/src/ReactChildFiber.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ function createChildReconciler(
789789
// We treat the parent as the owner for stack purposes.
790790
created._debugOwner = returnFiber;
791791
created._debugTask = returnFiber._debugTask;
792+
// Make sure to not push again when handling the Fragment child.
792793
const prevDebugInfo = pushDebugInfo(newChild._debugInfo);
793794
created._debugInfo = currentDebugInfo;
794795
currentDebugInfo = prevDebugInfo;
@@ -1915,41 +1916,41 @@ function createChildReconciler(
19151916
}
19161917

19171918
if (isArray(newChild)) {
1918-
const prevDebugInfo = pushDebugInfo(newChild._debugInfo);
1919+
// We created a Fragment for this child with the debug info.
1920+
// No need to push again.
19191921
const firstChild = reconcileChildrenArray(
19201922
returnFiber,
19211923
currentFirstChild,
19221924
newChild,
19231925
lanes,
19241926
);
1925-
currentDebugInfo = prevDebugInfo;
19261927
return firstChild;
19271928
}
19281929

19291930
if (getIteratorFn(newChild)) {
1930-
const prevDebugInfo = pushDebugInfo(newChild._debugInfo);
1931+
// We created a Fragment for this child with the debug info.
1932+
// No need to push again.
19311933
const firstChild = reconcileChildrenIteratable(
19321934
returnFiber,
19331935
currentFirstChild,
19341936
newChild,
19351937
lanes,
19361938
);
1937-
currentDebugInfo = prevDebugInfo;
19381939
return firstChild;
19391940
}
19401941

19411942
if (
19421943
enableAsyncIterableChildren &&
19431944
typeof newChild[ASYNC_ITERATOR] === 'function'
19441945
) {
1945-
const prevDebugInfo = pushDebugInfo(newChild._debugInfo);
1946+
// We created a Fragment for this child with the debug info.
1947+
// No need to push again.
19461948
const firstChild = reconcileChildrenAsyncIteratable(
19471949
returnFiber,
19481950
currentFirstChild,
19491951
newChild,
19501952
lanes,
19511953
);
1952-
currentDebugInfo = prevDebugInfo;
19531954
return firstChild;
19541955
}
19551956

0 commit comments

Comments
 (0)