Skip to content

Commit 794ed49

Browse files
author
Brian Vaughn
committed
DevTools: Fix another Fast Refresh edge case
Don't untrack unmounted Fibers after logging errors/warnings because it sometimes causes prematurely untracking a force-remounted Fiber from Fast Refresh, which in turn causes DevTools to break when the component is later inspected. This is a hack but I'm not sure of a better workaround.
1 parent ebcec3c commit 794ed49

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2384,7 +2384,7 @@ describe('TreeListContext', () => {
23842384
);
23852385

23862386
expect(state).toMatchInlineSnapshot(`
2387-
✕ 0, ⚠ 1
2387+
✕ 0, ⚠ 2
23882388
[root]
23892389
▾ <Suspense>
23902390
<Child> ⚠

packages/react-devtools-shared/src/backend/renderer.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1516,7 +1516,10 @@ export function attach(
15161516
// We may also need to clean up after ourselves to avoid leaks.
15171517
// See inline comments in onErrorOrWarning() for more info.
15181518
if (isFiberMountedImpl(fiber) !== MOUNTED) {
1519-
untrackFiberID(fiber);
1519+
// HACK Cleaning up "unmounted" Fibers here can cause problems with Fast Refresh.
1520+
// Since warnings and errors are generally used in DEV mode,
1521+
// it may be better to ignore this kind of potential leak case rather than break Fast Refresh.
1522+
// untrackFiberID(fiber);
15201523
return;
15211524
}
15221525

0 commit comments

Comments
 (0)