@@ -94,7 +94,12 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
94
94
}
95
95
}
96
96
97
- function beginHostRoot ( current , workInProgress , renderPriority ) {
97
+ function beginHostRoot (
98
+ current : Fiber | null ,
99
+ workInProgress : Fiber ,
100
+ nextProps : mixed ,
101
+ renderPriority : PriorityLevel
102
+ ) : Fiber | null {
98
103
const root = ( workInProgress . stateNode : FiberRoot ) ;
99
104
if ( root . pendingContext ) {
100
105
pushTopLevelContextObject (
@@ -156,17 +161,12 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
156
161
function beginHostPortal (
157
162
current : Fiber | null ,
158
163
workInProgress : Fiber ,
164
+ nextChildren : mixed ,
159
165
renderPriority : PriorityLevel ,
160
166
) : Fiber | null {
161
167
pushHostContainer ( workInProgress , workInProgress . stateNode . containerInfo ) ;
162
168
163
169
const memoizedChildren = workInProgress . memoizedProps ;
164
- let nextChildren = workInProgress . pendingProps ;
165
- if ( nextChildren === null ) {
166
- nextChildren = memoizedChildren ;
167
- invariant ( nextChildren !== null , 'Must have pending or memoized props.' ) ;
168
- }
169
-
170
170
if ( nextChildren === memoizedChildren && ! hasContextChanged ( ) ) {
171
171
return bailout ( current , workInProgress , nextChildren , null , renderPriority ) ;
172
172
}
@@ -182,15 +182,15 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
182
182
) ;
183
183
}
184
184
185
- function beginHostComponent ( current , workInProgress , renderPriority ) {
185
+ function beginHostComponent (
186
+ current : Fiber | null ,
187
+ workInProgress : Fiber ,
188
+ nextProps : mixed ,
189
+ renderPriority : PriorityLevel ,
190
+ ) : Fiber | null {
186
191
pushHostContext ( workInProgress ) ;
187
192
188
193
const memoizedProps = workInProgress . memoizedProps ;
189
- let nextProps = workInProgress . pendingProps ;
190
- if ( nextProps === null ) {
191
- nextProps = memoizedProps ;
192
- invariant ( nextProps !== null , 'Must have pending or memoized props.' ) ;
193
- }
194
194
195
195
// Check if the ref has changed and schedule an effect. This should happen
196
196
// even if we bailout.
@@ -250,13 +250,13 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
250
250
) ;
251
251
}
252
252
253
- function beginHostText ( current , workInProgress , renderPriority ) {
253
+ function beginHostText (
254
+ current : Fiber | null ,
255
+ workInProgress : Fiber ,
256
+ nextProps : mixed ,
257
+ renderPriority : PriorityLevel ,
258
+ ) : Fiber | null {
254
259
const memoizedProps = workInProgress . memoizedProps ;
255
- let nextProps = workInProgress . pendingProps ;
256
- if ( nextProps === null ) {
257
- nextProps = memoizedProps ;
258
- invariant ( nextProps !== null , 'Must have pending or memoized props.' ) ;
259
- }
260
260
if ( nextProps === memoizedProps ) {
261
261
return bailout ( current , workInProgress , nextProps , null , renderPriority ) ;
262
262
}
@@ -273,23 +273,21 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
273
273
}
274
274
275
275
function beginIndeterminateComponent (
276
- current ,
277
- workInProgress ,
278
- renderPriority ,
279
- ) {
276
+ current : Fiber | null ,
277
+ workInProgress : Fiber ,
278
+ nextProps : mixed ,
279
+ renderPriority : PriorityLevel ,
280
+ ) : Fiber | null {
280
281
invariant (
281
282
current === null ,
282
283
'An indeterminate component should never have mounted. This error is ' +
283
284
'likely caused by a bug in React. Please file an issue.' ,
284
285
) ;
285
286
286
287
const fn = workInProgress . type ;
287
- const nextProps = workInProgress . pendingProps ;
288
288
let unmaskedContext = getUnmaskedContext ( workInProgress ) ;
289
289
let nextContext = getMaskedContext ( workInProgress , unmaskedContext ) ;
290
290
291
- invariant ( nextProps !== null , 'Must have pending props.' ) ;
292
-
293
291
// This is either a functional component or a module-style class component.
294
292
let value ;
295
293
if ( __DEV__ ) {
@@ -382,16 +380,15 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
382
380
}
383
381
}
384
382
385
- function beginFunctionalComponent ( current , workInProgress , renderPriority ) {
383
+ function beginFunctionalComponent (
384
+ current : Fiber | null ,
385
+ workInProgress : Fiber ,
386
+ nextProps : mixed ,
387
+ renderPriority : PriorityLevel ,
388
+ ) : Fiber | null {
386
389
const fn = workInProgress . type ;
387
390
388
391
const memoizedProps = workInProgress . memoizedProps ;
389
- let nextProps = workInProgress . pendingProps ;
390
- if ( nextProps === null ) {
391
- nextProps = memoizedProps ;
392
- invariant ( nextProps !== null , 'Must have pending or memoized props.' ) ;
393
- }
394
-
395
392
if (
396
393
( nextProps === memoizedProps && ! hasContextChanged ( ) ) ||
397
394
// TODO: Disable this before release, since it is not part of the public
@@ -474,6 +471,7 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
474
471
function beginClassComponent (
475
472
current : Fiber | null ,
476
473
workInProgress : Fiber ,
474
+ nextProps : mixed ,
477
475
renderPriority : PriorityLevel ,
478
476
) : Fiber | null {
479
477
// Push context providers early to prevent context stack mismatches. During
@@ -483,12 +481,6 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
483
481
484
482
const ctor = workInProgress . type ;
485
483
486
- const memoizedProps = workInProgress . memoizedProps ;
487
- let nextProps = workInProgress . pendingProps ;
488
- if ( nextProps === null ) {
489
- nextProps = memoizedProps ;
490
- invariant ( nextProps !== null , 'Must have pending or memoized props.' ) ;
491
- }
492
484
const unmaskedContext = getUnmaskedContext ( workInProgress ) ;
493
485
const nextContext = getMaskedContext ( workInProgress , unmaskedContext ) ;
494
486
@@ -827,15 +819,10 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
827
819
function beginFragment (
828
820
current : Fiber | null ,
829
821
workInProgress : Fiber ,
822
+ nextProps : mixed ,
830
823
renderPriority : PriorityLevel ,
831
824
) : Fiber | null {
832
825
const memoizedProps = workInProgress . memoizedProps ;
833
- let nextProps = workInProgress . pendingProps ;
834
- if ( nextProps === null ) {
835
- nextProps = memoizedProps ;
836
- invariant ( nextProps !== null , 'Must have pending or memoized props.' ) ;
837
- }
838
-
839
826
if ( nextProps === memoizedProps && ! hasContextChanged ( ) ) {
840
827
// No changes to props or context. Bailout.
841
828
return bailout ( current , workInProgress , nextProps , null , renderPriority ) ;
@@ -1271,7 +1258,6 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
1271
1258
return resetToCurrent ( current , workInProgress , renderPriority ) ;
1272
1259
}
1273
1260
1274
-
1275
1261
function beginWork (
1276
1262
current : Fiber | null ,
1277
1263
workInProgress : Fiber ,
@@ -1288,31 +1274,40 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
1288
1274
workInProgress . firstEffect = null ;
1289
1275
workInProgress . lastEffect = null ;
1290
1276
1277
+ let nextProps = workInProgress . pendingProps ;
1278
+ if ( nextProps === null ) {
1279
+ // If there are no pending props, re-use the memoized props.
1280
+ nextProps = workInProgress . memoizedProps ;
1281
+ invariant ( nextProps !== null , 'Must have pending or memoized props.' ) ;
1282
+ }
1283
+
1291
1284
switch ( workInProgress . tag ) {
1292
1285
case HostRoot :
1293
- return beginHostRoot ( current , workInProgress , renderPriority ) ;
1286
+ return beginHostRoot ( current , workInProgress , nextProps , renderPriority ) ;
1294
1287
case HostPortal :
1295
- return beginHostPortal ( current , workInProgress , renderPriority ) ;
1288
+ return beginHostPortal ( current , workInProgress , nextProps , renderPriority ) ;
1296
1289
case HostComponent :
1297
- return beginHostComponent ( current , workInProgress , renderPriority ) ;
1290
+ return beginHostComponent ( current , workInProgress , nextProps , renderPriority ) ;
1298
1291
case HostText :
1299
- return beginHostText ( current , workInProgress , renderPriority ) ;
1292
+ return beginHostText ( current , workInProgress , nextProps , renderPriority ) ;
1300
1293
case IndeterminateComponent :
1301
1294
return beginIndeterminateComponent (
1302
1295
current ,
1303
1296
workInProgress ,
1297
+ nextProps ,
1304
1298
renderPriority ,
1305
1299
) ;
1306
1300
case FunctionalComponent :
1307
1301
return beginFunctionalComponent (
1308
1302
current ,
1309
1303
workInProgress ,
1304
+ nextProps ,
1310
1305
renderPriority ,
1311
1306
) ;
1312
1307
case ClassComponent :
1313
- return beginClassComponent ( current , workInProgress , renderPriority ) ;
1308
+ return beginClassComponent ( current , workInProgress , nextProps , renderPriority ) ;
1314
1309
case Fragment :
1315
- return beginFragment ( current , workInProgress , renderPriority ) ;
1310
+ return beginFragment ( current , workInProgress , nextProps , renderPriority ) ;
1316
1311
default :
1317
1312
invariant (
1318
1313
false ,
0 commit comments