Skip to content

Commit

Permalink
DevTools: Fix another Fast Refresh edge case
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Brian Vaughn committed May 20, 2021
1 parent ebcec3c commit 80d0cdb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/react-devtools-shared/src/backend/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1516,7 +1516,10 @@ export function attach(
// We may also need to clean up after ourselves to avoid leaks.
// See inline comments in onErrorOrWarning() for more info.
if (isFiberMountedImpl(fiber) !== MOUNTED) {
untrackFiberID(fiber);
// HACK Cleaning up "unmounted" Fibers here can cause problems with Fast Refresh.
// Since warnings and errors are generally used in DEV mode,
// it may be better to ignore this kind of potential leak case rather than break Fast Refresh.
// untrackFiberID(fiber);
return;
}

Expand Down

0 comments on commit 80d0cdb

Please sign in to comment.