@@ -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 > =
@@ -1331,10 +1325,6 @@ export function attach(
1331
1325
const newRoot = createFiberInstance ( current ) ;
1332
1326
rootToFiberInstanceMap . set ( root , newRoot ) ;
1333
1327
idToDevToolsInstanceMap . set ( newRoot . id , newRoot ) ;
1334
- fiberToFiberInstanceMap . set ( current , newRoot ) ;
1335
- if ( alternate ) {
1336
- fiberToFiberInstanceMap . set ( alternate , newRoot ) ;
1337
- }
1338
1328
1339
1329
// Before the traversals, remember to start tracking
1340
1330
// our path in case we have selection to restore.
@@ -2016,14 +2006,6 @@ export function attach(
2016
2006
} else {
2017
2007
fiberInstance = createFiberInstance ( fiber ) ;
2018
2008
}
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
2009
idToDevToolsInstanceMap . set ( fiberInstance . id , fiberInstance ) ;
2028
2010
2029
2011
const id = fiberInstance . id ;
@@ -2237,16 +2219,6 @@ export function attach(
2237
2219
2238
2220
idToDevToolsInstanceMap . delete ( fiberInstance . id ) ;
2239
2221
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
2222
untrackFiber ( fiberInstance , fiber ) ;
2251
2223
}
2252
2224
@@ -3084,9 +3056,6 @@ export function attach(
3084
3056
shouldResetChildren = true ;
3085
3057
}
3086
3058
3087
- // Register the new alternate in case it's not already in.
3088
- fiberToFiberInstanceMap . set ( nextChild , fiberInstance ) ;
3089
-
3090
3059
moveChild ( fiberInstance , previousSiblingOfExistingInstance ) ;
3091
3060
3092
3061
if (
@@ -3467,11 +3436,6 @@ export function attach(
3467
3436
const newRoot = createFiberInstance ( current ) ;
3468
3437
rootToFiberInstanceMap . set ( root , newRoot ) ;
3469
3438
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
3439
currentRoot = newRoot ;
3476
3440
setRootPseudoKey ( currentRoot . id , root . current ) ;
3477
3441
@@ -3541,11 +3505,6 @@ export function attach(
3541
3505
rootInstance = createFiberInstance ( current ) ;
3542
3506
rootToFiberInstanceMap . set ( root , rootInstance ) ;
3543
3507
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
3508
} else {
3550
3509
prevFiber = rootInstance . data ;
3551
3510
}
0 commit comments