File tree Expand file tree Collapse file tree 2 files changed +22
-12
lines changed
packages/react-reconciler/src Expand file tree Collapse file tree 2 files changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ import {
47
47
commitHydratedSuspenseInstance ,
48
48
removeChildFromContainer ,
49
49
removeChild ,
50
+ clearSingleton ,
51
+ acquireSingletonInstance ,
50
52
} from './ReactFiberConfig' ;
51
53
import { captureCommitPhaseError } from './ReactFiberWorkLoop' ;
52
54
@@ -413,3 +415,21 @@ export function commitHostHydratedSuspense(
413
415
captureCommitPhaseError ( finishedWork , finishedWork . return , error ) ;
414
416
}
415
417
}
418
+
419
+ export function commitHostSingleton ( finishedWork : Fiber ) {
420
+ const singleton = finishedWork . stateNode ;
421
+ const props = finishedWork . memoizedProps ;
422
+
423
+ try {
424
+ // This was a new mount, we need to clear and set initial properties
425
+ clearSingleton ( singleton ) ;
426
+ acquireSingletonInstance (
427
+ finishedWork . type ,
428
+ props ,
429
+ singleton ,
430
+ finishedWork ,
431
+ ) ;
432
+ } catch ( error ) {
433
+ captureCommitPhaseError ( finishedWork , finishedWork . return , error ) ;
434
+ }
435
+ }
Original file line number Diff line number Diff line change @@ -121,8 +121,6 @@ import {
121
121
prepareForCommit ,
122
122
beforeActiveInstanceBlur ,
123
123
detachDeletedInstance ,
124
- clearSingleton ,
125
- acquireSingletonInstance ,
126
124
releaseSingletonInstance ,
127
125
getHoistableRoot ,
128
126
acquireResource ,
@@ -210,6 +208,7 @@ import {
210
208
commitHostHydratedSuspense ,
211
209
commitHostRemoveChildFromContainer ,
212
210
commitHostRemoveChild ,
211
+ commitHostSingleton ,
213
212
} from './ReactFiberCommitHostEffects' ;
214
213
215
214
// Used during the commit phase to track the state of the Offscreen component stack.
@@ -1852,16 +1851,7 @@ function commitMutationEffectsOnFiber(
1852
1851
if ( flags & Update ) {
1853
1852
const previousWork = finishedWork . alternate ;
1854
1853
if ( previousWork === null ) {
1855
- const singleton = finishedWork . stateNode ;
1856
- const props = finishedWork . memoizedProps ;
1857
- // This was a new mount, we need to clear and set initial properties
1858
- clearSingleton ( singleton ) ;
1859
- acquireSingletonInstance (
1860
- finishedWork . type ,
1861
- props ,
1862
- singleton ,
1863
- finishedWork ,
1864
- ) ;
1854
+ commitHostSingleton ( finishedWork ) ;
1865
1855
}
1866
1856
}
1867
1857
}
You can’t perform that action at this time.
0 commit comments