@@ -829,12 +829,6 @@ export function attach(
829829 throw Error ( 'Cannot modify filter preferences while profiling' ) ;
830830 }
831831
832- unmountAndRemountAllRoots(() => {
833- applyComponentFilters ( componentFilters ) ;
834- } );
835- }
836-
837- function unmountAndRemountAllRoots ( callback ?: Function ) {
838832 // Recursively unmount all roots.
839833 hook.getFiberRoots(rendererID).forEach(root => {
840834 currentRootID = getOrGenerateFiberID ( root . current ) ;
@@ -846,9 +840,7 @@ export function attach(
846840 currentRootID = - 1 ;
847841 } );
848842
849- if ( typeof callback === 'function' ) {
850- callback ( ) ;
851- }
843+ applyComponentFilters(componentFilters);
852844
853845 // Reset pseudo counters so that new path selections will be persisted.
854846 rootDisplayNameCounter.clear();
@@ -1797,20 +1789,6 @@ export function attach(
17971789 ) ;
17981790 }
17991791
1800- const unsafeID = getFiberIDUnsafe ( fiber ) ;
1801- if ( fiber . _debugNeedsRemount ) {
1802- if ( unsafeID === null ) {
1803- // This inidicates a case we can't recover from:
1804- // Fast Refresh has force remounted a component in a way that we don't have an id for.
1805- // We could throw but that's a bad user experience.
1806- // Or we could ignore the unmount but then Store might end up with a duplicate node.
1807- // So a fallback is to completely reset the Store.
1808- // This is costly but since Fast Refresh is only used in DEV builds, it should be okay.
1809- setTimeout ( unmountAndRemountAllRoots , 0 ) ;
1810- return ;
1811- }
1812- }
1813-
18141792 if ( trackedPathMatchFiber !== null ) {
18151793 // We're in the process of trying to restore previous selection.
18161794 // If this fiber matched but is being unmounted, there's no use trying.
@@ -1823,11 +1801,14 @@ export function attach(
18231801 }
18241802 }
18251803
1804+ const unsafeID = getFiberIDUnsafe ( fiber ) ;
18261805 if ( unsafeID === null ) {
18271806 // If we've never seen this Fiber, it might be inside of a legacy render Suspense fragment (so the store is not even aware of it).
18281807 // In that case we can just ignore it or it will cause errors later on.
18291808 // One example of this is a Lazy component that never resolves before being unmounted.
18301809 //
1810+ // This also might indicate a Fast Refresh force-remount scenario.
1811+ //
18311812 // TODO: This is fragile and can obscure actual bugs.
18321813 return ;
18331814 }
0 commit comments