@@ -153,11 +153,7 @@ const callComponentWillUnmountWithTimer = function(current, instance) {
153153} ;
154154
155155// Capture errors so they don't interrupt unmounting.
156- function safelyCallComponentWillUnmount (
157- current : Fiber ,
158- instance : any ,
159- nearestMountedAncestor : Fiber | null ,
160- ) {
156+ function safelyCallComponentWillUnmount ( current : Fiber , instance : any ) {
161157 if ( __DEV__ ) {
162158 invokeGuardedCallback (
163159 null ,
@@ -168,32 +164,32 @@ function safelyCallComponentWillUnmount(
168164 ) ;
169165 if ( hasCaughtError ( ) ) {
170166 const unmountError = clearCaughtError ( ) ;
171- captureCommitPhaseError ( current , nearestMountedAncestor , unmountError ) ;
167+ captureCommitPhaseError ( current , unmountError ) ;
172168 }
173169 } else {
174170 try {
175171 callComponentWillUnmountWithTimer ( current , instance ) ;
176172 } catch ( unmountError ) {
177- captureCommitPhaseError ( current , nearestMountedAncestor , unmountError ) ;
173+ captureCommitPhaseError ( current , unmountError ) ;
178174 }
179175 }
180176}
181177
182- function safelyDetachRef ( current : Fiber , nearestMountedAncestor : Fiber | null ) {
178+ function safelyDetachRef ( current : Fiber ) {
183179 const ref = current . ref ;
184180 if ( ref !== null ) {
185181 if ( typeof ref === 'function' ) {
186182 if ( __DEV__ ) {
187183 invokeGuardedCallback ( null , ref , null , null ) ;
188184 if ( hasCaughtError ( ) ) {
189185 const refError = clearCaughtError ( ) ;
190- captureCommitPhaseError ( current , nearestMountedAncestor , refError ) ;
186+ captureCommitPhaseError ( current , refError ) ;
191187 }
192188 } else {
193189 try {
194190 ref ( null ) ;
195191 } catch ( refError ) {
196- captureCommitPhaseError ( current , nearestMountedAncestor , refError ) ;
192+ captureCommitPhaseError ( current , refError ) ;
197193 }
198194 }
199195 } else {
@@ -202,22 +198,18 @@ function safelyDetachRef(current: Fiber, nearestMountedAncestor: Fiber | null) {
202198 }
203199}
204200
205- function safelyCallDestroy (
206- current : Fiber ,
207- nearestMountedAncestor : Fiber | null ,
208- destroy : ( ) = > void ,
209- ) {
201+ function safelyCallDestroy ( current : Fiber , destroy : ( ) = > void ) {
210202 if ( __DEV__ ) {
211203 invokeGuardedCallback ( null , destroy , null ) ;
212204 if ( hasCaughtError ( ) ) {
213205 const error = clearCaughtError ( ) ;
214- captureCommitPhaseError ( current , nearestMountedAncestor , error ) ;
206+ captureCommitPhaseError ( current , error ) ;
215207 }
216208 } else {
217209 try {
218210 destroy ( ) ;
219211 } catch ( error ) {
220- captureCommitPhaseError ( current , nearestMountedAncestor , error ) ;
212+ captureCommitPhaseError ( current , error ) ;
221213 }
222214 }
223215}
@@ -874,7 +866,6 @@ function commitDetachRef(current: Fiber) {
874866function commitUnmount (
875867 finishedRoot : FiberRoot ,
876868 current : Fiber ,
877- nearestMountedAncestor : Fiber | null ,
878869 renderPriorityLevel : ReactPriorityLevel ,
879870) : void {
880871 onCommitUnmount ( current ) ;
@@ -904,10 +895,10 @@ function commitUnmount(
904895 current . mode & ProfileMode
905896 ) {
906897 startLayoutEffectTimer ( ) ;
907- safelyCallDestroy ( current , nearestMountedAncestor , destroy ) ;
898+ safelyCallDestroy ( current , destroy ) ;
908899 recordLayoutEffectDuration ( current ) ;
909900 } else {
910- safelyCallDestroy ( current , nearestMountedAncestor , destroy ) ;
901+ safelyCallDestroy ( current , destroy ) ;
911902 }
912903 }
913904 }
@@ -918,32 +909,23 @@ function commitUnmount(
918909 return ;
919910 }
920911 case ClassComponent : {
921- safelyDetachRef ( current , nearestMountedAncestor ) ;
912+ safelyDetachRef ( current ) ;
922913 const instance = current . stateNode ;
923914 if ( typeof instance . componentWillUnmount === 'function' ) {
924- safelyCallComponentWillUnmount (
925- current ,
926- instance ,
927- nearestMountedAncestor ,
928- ) ;
915+ safelyCallComponentWillUnmount ( current , instance ) ;
929916 }
930917 return ;
931918 }
932919 case HostComponent : {
933- safelyDetachRef ( current , nearestMountedAncestor ) ;
920+ safelyDetachRef ( current ) ;
934921 return ;
935922 }
936923 case HostPortal : {
937924 // TODO: this is recursive.
938925 // We are also not using this parent because
939926 // the portal will get pushed immediately.
940927 if ( supportsMutation ) {
941- unmountHostComponents (
942- finishedRoot ,
943- current ,
944- nearestMountedAncestor ,
945- renderPriorityLevel ,
946- ) ;
928+ unmountHostComponents ( finishedRoot , current , renderPriorityLevel ) ;
947929 } else if ( supportsPersistence ) {
948930 emptyPortalContainer ( current ) ;
949931 }
@@ -973,7 +955,7 @@ function commitUnmount(
973955 }
974956 case ScopeComponent : {
975957 if ( enableScopeAPI ) {
976- safelyDetachRef ( current , nearestMountedAncestor ) ;
958+ safelyDetachRef ( current ) ;
977959 }
978960 return ;
979961 }
@@ -983,7 +965,6 @@ function commitUnmount(
983965function commitNestedUnmounts (
984966 finishedRoot : FiberRoot ,
985967 root : Fiber ,
986- nearestMountedAncestor : Fiber | null ,
987968 renderPriorityLevel : ReactPriorityLevel ,
988969) : void {
989970 // While we're inside a removed host node we don't want to call
@@ -993,12 +974,7 @@ function commitNestedUnmounts(
993974 // we do an inner loop while we're still inside the host node.
994975 let node : Fiber = root ;
995976 while ( true ) {
996- commitUnmount (
997- finishedRoot ,
998- node ,
999- nearestMountedAncestor ,
1000- renderPriorityLevel ,
1001- ) ;
977+ commitUnmount ( finishedRoot , node , renderPriorityLevel ) ;
1002978 // Visit children because they may contain more composite or host nodes.
1003979 // Skip portals because commitUnmount() currently visits them recursively.
1004980 if (
@@ -1289,7 +1265,6 @@ function insertOrAppendPlacementNode(
12891265function unmountHostComponents (
12901266 finishedRoot : FiberRoot ,
12911267 current : Fiber ,
1292- nearestMountedAncestor : Fiber | null ,
12931268 renderPriorityLevel : ReactPriorityLevel ,
12941269) : void {
12951270 // We only have the top Fiber that was deleted but we need to recurse down its
@@ -1339,12 +1314,7 @@ function unmountHostComponents(
13391314 }
13401315
13411316 if ( node . tag === HostComponent || node . tag === HostText ) {
1342- commitNestedUnmounts (
1343- finishedRoot ,
1344- node ,
1345- nearestMountedAncestor ,
1346- renderPriorityLevel ,
1347- ) ;
1317+ commitNestedUnmounts ( finishedRoot , node , renderPriorityLevel ) ;
13481318 // After all the children have unmounted, it is now safe to remove the
13491319 // node from the tree.
13501320 if ( currentParentIsContainer ) {
@@ -1361,12 +1331,7 @@ function unmountHostComponents(
13611331 // Don't visit children because we already visited them.
13621332 } else if ( enableFundamentalAPI && node . tag === FundamentalComponent ) {
13631333 const fundamentalNode = node . stateNode . instance ;
1364- commitNestedUnmounts (
1365- finishedRoot ,
1366- node ,
1367- nearestMountedAncestor ,
1368- renderPriorityLevel ,
1369- ) ;
1334+ commitNestedUnmounts ( finishedRoot , node , renderPriorityLevel ) ;
13701335 // After all the children have unmounted, it is now safe to remove the
13711336 // node from the tree.
13721337 if ( currentParentIsContainer ) {
@@ -1418,12 +1383,7 @@ function unmountHostComponents(
14181383 continue ;
14191384 }
14201385 } else {
1421- commitUnmount (
1422- finishedRoot ,
1423- node ,
1424- nearestMountedAncestor ,
1425- renderPriorityLevel ,
1426- ) ;
1386+ commitUnmount ( finishedRoot , node , renderPriorityLevel ) ;
14271387 // Visit children because we may find more host components below.
14281388 if ( node . child !== null ) {
14291389 node . child . return = node ;
@@ -1453,26 +1413,15 @@ function unmountHostComponents(
14531413function commitDeletion (
14541414 finishedRoot : FiberRoot ,
14551415 current : Fiber ,
1456- nearestMountedAncestor : Fiber | null ,
14571416 renderPriorityLevel : ReactPriorityLevel ,
14581417) : void {
14591418 if ( supportsMutation ) {
14601419 // Recursively delete all host nodes from the parent.
14611420 // Detach refs and call componentWillUnmount() on the whole subtree.
1462- unmountHostComponents (
1463- finishedRoot ,
1464- current ,
1465- nearestMountedAncestor ,
1466- renderPriorityLevel ,
1467- ) ;
1421+ unmountHostComponents ( finishedRoot , current , renderPriorityLevel ) ;
14681422 } else {
14691423 // Detach refs and call componentWillUnmount() on the whole subtree.
1470- commitNestedUnmounts (
1471- finishedRoot ,
1472- current ,
1473- nearestMountedAncestor ,
1474- renderPriorityLevel ,
1475- ) ;
1424+ commitNestedUnmounts ( finishedRoot , current , renderPriorityLevel ) ;
14761425 }
14771426 const alternate = current . alternate ;
14781427 detachFiberMutation ( current ) ;
0 commit comments