@@ -744,13 +744,7 @@ const knownEnvironmentNames: Set<string> = new Set();
744
744
// Map of FiberRoot to their root FiberInstance.
745
745
const rootToFiberInstanceMap : Map < FiberRoot , FiberInstance > = new Map ( ) ;
746
746
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.
754
748
// This Map is used to e.g. get the display name for a Fiber or schedule an update,
755
749
// operations that should be the same whether the current and work-in-progress Fiber is used.
756
750
const idToDevToolsInstanceMap : Map < number , FiberInstance | VirtualInstance > =
@@ -1327,14 +1321,9 @@ export function attach(
1327
1321
// Recursively re-mount all roots with new filter criteria applied.
1328
1322
hook . getFiberRoots ( rendererID ) . forEach ( root => {
1329
1323
const current = root . current ;
1330
- const alternate = current . alternate ;
1331
1324
const newRoot = createFiberInstance ( current ) ;
1332
1325
rootToFiberInstanceMap . set ( root , newRoot ) ;
1333
1326
idToDevToolsInstanceMap . set ( newRoot . id , newRoot ) ;
1334
- fiberToFiberInstanceMap . set ( current , newRoot ) ;
1335
- if ( alternate ) {
1336
- fiberToFiberInstanceMap . set ( alternate , newRoot ) ;
1337
- }
1338
1327
1339
1328
// Before the traversals, remember to start tracking
1340
1329
// our path in case we have selection to restore.
@@ -2016,14 +2005,6 @@ export function attach(
2016
2005
} else {
2017
2006
fiberInstance = createFiberInstance ( fiber ) ;
2018
2007
}
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
- }
2027
2008
idToDevToolsInstanceMap . set ( fiberInstance . id , fiberInstance ) ;
2028
2009
2029
2010
const id = fiberInstance . id ;
@@ -2237,16 +2218,6 @@ export function attach(
2237
2218
2238
2219
idToDevToolsInstanceMap . delete ( fiberInstance . id ) ;
2239
2220
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
-
2250
2221
untrackFiber ( fiberInstance , fiber ) ;
2251
2222
}
2252
2223
@@ -3084,9 +3055,6 @@ export function attach(
3084
3055
shouldResetChildren = true ;
3085
3056
}
3086
3057
3087
- // Register the new alternate in case it's not already in.
3088
- fiberToFiberInstanceMap . set ( nextChild , fiberInstance ) ;
3089
-
3090
3058
moveChild ( fiberInstance , previousSiblingOfExistingInstance ) ;
3091
3059
3092
3060
if (
@@ -3467,11 +3435,6 @@ export function attach(
3467
3435
const newRoot = createFiberInstance ( current ) ;
3468
3436
rootToFiberInstanceMap . set ( root , newRoot ) ;
3469
3437
idToDevToolsInstanceMap . set ( newRoot . id , newRoot ) ;
3470
- fiberToFiberInstanceMap . set ( current , newRoot ) ;
3471
- const alternate = current . alternate ;
3472
- if ( alternate ) {
3473
- fiberToFiberInstanceMap . set ( alternate , newRoot ) ;
3474
- }
3475
3438
currentRoot = newRoot ;
3476
3439
setRootPseudoKey ( currentRoot . id , root . current ) ;
3477
3440
@@ -3541,11 +3504,6 @@ export function attach(
3541
3504
rootInstance = createFiberInstance ( current ) ;
3542
3505
rootToFiberInstanceMap . set ( root , rootInstance ) ;
3543
3506
idToDevToolsInstanceMap . set ( rootInstance . id , rootInstance ) ;
3544
- fiberToFiberInstanceMap . set ( current , rootInstance ) ;
3545
- const alternate = current . alternate ;
3546
- if ( alternate ) {
3547
- fiberToFiberInstanceMap . set ( alternate , rootInstance ) ;
3548
- }
3549
3507
} else {
3550
3508
prevFiber = rootInstance . data ;
3551
3509
}
0 commit comments