@@ -744,13 +744,7 @@ const knownEnvironmentNames: Set<string> = new Set();
744744// Map of FiberRoot to their root FiberInstance.
745745const rootToFiberInstanceMap : Map < FiberRoot , FiberInstance > = new Map ( ) ;
746746
747- // Map of one or more Fibers in a pair to their unique id number.
748- // We track both Fibers to support Fast Refresh,
749- // which may forcefully replace one of the pair as part of hot reloading.
750- // In that case it's still important to be able to locate the previous ID during subsequent renders.
751- const fiberToFiberInstanceMap : Map < Fiber , FiberInstance > = new Map ( ) ;
752-
753- // Map of id to one (arbitrary) Fiber in a pair.
747+ // Map of id to FiberInstance or VirtualInstance.
754748// This Map is used to e.g. get the display name for a Fiber or schedule an update,
755749// operations that should be the same whether the current and work-in-progress Fiber is used.
756750const idToDevToolsInstanceMap : Map < number , FiberInstance | VirtualInstance > =
@@ -1327,14 +1321,9 @@ export function attach(
13271321 // Recursively re-mount all roots with new filter criteria applied.
13281322 hook . getFiberRoots ( rendererID ) . forEach ( root => {
13291323 const current = root . current ;
1330- const alternate = current . alternate ;
13311324 const newRoot = createFiberInstance ( current ) ;
13321325 rootToFiberInstanceMap . set ( root , newRoot ) ;
13331326 idToDevToolsInstanceMap . set ( newRoot . id , newRoot ) ;
1334- fiberToFiberInstanceMap . set ( current , newRoot ) ;
1335- if ( alternate ) {
1336- fiberToFiberInstanceMap . set ( alternate , newRoot ) ;
1337- }
13381327
13391328 // Before the traversals, remember to start tracking
13401329 // our path in case we have selection to restore.
@@ -2016,14 +2005,6 @@ export function attach(
20162005 } else {
20172006 fiberInstance = createFiberInstance ( fiber ) ;
20182007 }
2019- // If this already exists behind a different FiberInstance, we intentionally
2020- // override it here to claim the fiber as part of this new instance.
2021- // E.g. if it was part of a reparenting.
2022- fiberToFiberInstanceMap . set ( fiber , fiberInstance ) ;
2023- const alternate = fiber . alternate ;
2024- if ( alternate !== null && fiberToFiberInstanceMap . has ( alternate ) ) {
2025- fiberToFiberInstanceMap . set ( alternate , fiberInstance ) ;
2026- }
20272008 idToDevToolsInstanceMap . set ( fiberInstance . id , fiberInstance ) ;
20282009
20292010 const id = fiberInstance . id ;
@@ -2237,16 +2218,6 @@ export function attach(
22372218
22382219 idToDevToolsInstanceMap . delete ( fiberInstance . id ) ;
22392220
2240- if ( fiberToFiberInstanceMap . get ( fiber ) === fiberInstance ) {
2241- fiberToFiberInstanceMap . delete ( fiber ) ;
2242- }
2243- const { alternate } = fiber ;
2244- if ( alternate !== null ) {
2245- if ( fiberToFiberInstanceMap . get ( alternate ) === fiberInstance ) {
2246- fiberToFiberInstanceMap . delete ( alternate ) ;
2247- }
2248- }
2249-
22502221 untrackFiber ( fiberInstance , fiber ) ;
22512222 }
22522223
@@ -3084,9 +3055,6 @@ export function attach(
30843055 shouldResetChildren = true ;
30853056 }
30863057
3087- // Register the new alternate in case it's not already in.
3088- fiberToFiberInstanceMap . set ( nextChild , fiberInstance ) ;
3089-
30903058 moveChild ( fiberInstance , previousSiblingOfExistingInstance ) ;
30913059
30923060 if (
@@ -3467,11 +3435,6 @@ export function attach(
34673435 const newRoot = createFiberInstance ( current ) ;
34683436 rootToFiberInstanceMap . set ( root , newRoot ) ;
34693437 idToDevToolsInstanceMap . set ( newRoot . id , newRoot ) ;
3470- fiberToFiberInstanceMap . set ( current , newRoot ) ;
3471- const alternate = current . alternate ;
3472- if ( alternate ) {
3473- fiberToFiberInstanceMap . set ( alternate , newRoot ) ;
3474- }
34753438 currentRoot = newRoot ;
34763439 setRootPseudoKey ( currentRoot . id , root . current ) ;
34773440
@@ -3541,11 +3504,6 @@ export function attach(
35413504 rootInstance = createFiberInstance ( current ) ;
35423505 rootToFiberInstanceMap . set ( root , rootInstance ) ;
35433506 idToDevToolsInstanceMap . set ( rootInstance . id , rootInstance ) ;
3544- fiberToFiberInstanceMap . set ( current , rootInstance ) ;
3545- const alternate = current . alternate ;
3546- if ( alternate ) {
3547- fiberToFiberInstanceMap . set ( alternate , rootInstance ) ;
3548- }
35493507 } else {
35503508 prevFiber = rootInstance . data ;
35513509 }
0 commit comments