@@ -75,7 +75,7 @@ export type HostConfig<T, P, I, TI, C, CX> = {
75
75
} ;
76
76
77
77
export type Reconciler < C , I , TI > = {
78
- mountContainer ( element : ReactNodeList , containerInfo : C , parentComponent : ? ReactComponent < any , any , any > ) : OpaqueNode ,
78
+ createContainer ( containerInfo : C ) : OpaqueNode ,
79
79
updateContainer ( element : ReactNodeList , container : OpaqueNode , parentComponent : ?ReactComponent < any , any, any > ) : void ,
80
80
performWithPriority ( priorityLevel : PriorityLevel , fn : Function ) : void ,
81
81
/* eslint-disable no-undef */
@@ -119,17 +119,10 @@ module.exports = function<T, P, I, TI, C, CX>(config : HostConfig<T, P, I, TI, C
119
119
120
120
return {
121
121
122
- mountContainer ( element : ReactNodeList , containerInfo : C , parentComponent : ?ReactComponent < any , any , any > , callback : ?Function ) : OpaqueNode {
123
- const context = getContextForSubtree ( parentComponent ) ;
124
- const root = createFiberRoot ( containerInfo , context ) ;
122
+ createContainer ( containerInfo : C ) : OpaqueNode {
123
+ const root = createFiberRoot ( containerInfo ) ;
125
124
const current = root . current ;
126
125
127
- scheduleTopLevelUpdate ( current , element , callback ) ;
128
-
129
- if ( __DEV__ && ReactFiberInstrumentation . debugTool ) {
130
- ReactFiberInstrumentation . debugTool . onMountContainer ( root ) ;
131
- }
132
-
133
126
// It may seem strange that we don't return the root here, but that will
134
127
// allow us to have containers that are in the middle of the tree instead
135
128
// of being roots.
@@ -141,19 +134,26 @@ module.exports = function<T, P, I, TI, C, CX>(config : HostConfig<T, P, I, TI, C
141
134
const root : FiberRoot = ( container . stateNode : any ) ;
142
135
const current = root . current ;
143
136
144
- root . pendingContext = getContextForSubtree ( parentComponent ) ;
145
-
146
- scheduleTopLevelUpdate ( current , element , callback ) ;
147
-
148
137
if ( __DEV__ ) {
149
138
if ( ReactFiberInstrumentation . debugTool ) {
150
- if ( element === null ) {
139
+ if ( current . alternate === null ) {
140
+ ReactFiberInstrumentation . debugTool . onMountContainer ( root ) ;
141
+ } else if ( element === null ) {
151
142
ReactFiberInstrumentation . debugTool . onUnmountContainer ( root ) ;
152
143
} else {
153
144
ReactFiberInstrumentation . debugTool . onUpdateContainer ( root ) ;
154
145
}
155
146
}
156
147
}
148
+
149
+ const context = getContextForSubtree ( parentComponent ) ;
150
+ if ( root . context === null ) {
151
+ root . context = context ;
152
+ } else {
153
+ root . pendingContext = context ;
154
+ }
155
+
156
+ scheduleTopLevelUpdate ( current , element , context , callback ) ;
157
157
} ,
158
158
159
159
performWithPriority ,
0 commit comments