@@ -94,7 +94,12 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
9494 }
9595 }
9696
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 {
98103 const root = ( workInProgress . stateNode : FiberRoot ) ;
99104 if ( root . pendingContext ) {
100105 pushTopLevelContextObject (
@@ -156,17 +161,12 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
156161 function beginHostPortal (
157162 current : Fiber | null ,
158163 workInProgress : Fiber ,
164+ nextChildren : mixed ,
159165 renderPriority : PriorityLevel ,
160166 ) : Fiber | null {
161167 pushHostContainer ( workInProgress , workInProgress . stateNode . containerInfo ) ;
162168
163169 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-
170170 if ( nextChildren === memoizedChildren && ! hasContextChanged ( ) ) {
171171 return bailout ( current , workInProgress , nextChildren , null , renderPriority ) ;
172172 }
@@ -182,15 +182,15 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
182182 ) ;
183183 }
184184
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 {
186191 pushHostContext ( workInProgress ) ;
187192
188193 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- }
194194
195195 // Check if the ref has changed and schedule an effect. This should happen
196196 // even if we bailout.
@@ -250,13 +250,13 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
250250 ) ;
251251 }
252252
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 {
254259 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- }
260260 if ( nextProps === memoizedProps ) {
261261 return bailout ( current , workInProgress , nextProps , null , renderPriority ) ;
262262 }
@@ -273,23 +273,21 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
273273 }
274274
275275 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 {
280281 invariant (
281282 current === null ,
282283 'An indeterminate component should never have mounted. This error is ' +
283284 'likely caused by a bug in React. Please file an issue.' ,
284285 ) ;
285286
286287 const fn = workInProgress . type ;
287- const nextProps = workInProgress . pendingProps ;
288288 let unmaskedContext = getUnmaskedContext ( workInProgress ) ;
289289 let nextContext = getMaskedContext ( workInProgress , unmaskedContext ) ;
290290
291- invariant ( nextProps !== null , 'Must have pending props.' ) ;
292-
293291 // This is either a functional component or a module-style class component.
294292 let value ;
295293 if ( __DEV__ ) {
@@ -382,16 +380,15 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
382380 }
383381 }
384382
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 {
386389 const fn = workInProgress . type ;
387390
388391 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-
395392 if (
396393 ( nextProps === memoizedProps && ! hasContextChanged ( ) ) ||
397394 // 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>(
474471 function beginClassComponent (
475472 current : Fiber | null ,
476473 workInProgress : Fiber ,
474+ nextProps : mixed ,
477475 renderPriority : PriorityLevel ,
478476 ) : Fiber | null {
479477 // 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>(
483481
484482 const ctor = workInProgress . type ;
485483
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- }
492484 const unmaskedContext = getUnmaskedContext ( workInProgress ) ;
493485 const nextContext = getMaskedContext ( workInProgress , unmaskedContext ) ;
494486
@@ -827,15 +819,10 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
827819 function beginFragment (
828820 current : Fiber | null ,
829821 workInProgress : Fiber ,
822+ nextProps : mixed ,
830823 renderPriority : PriorityLevel ,
831824 ) : Fiber | null {
832825 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-
839826 if ( nextProps === memoizedProps && ! hasContextChanged ( ) ) {
840827 // No changes to props or context. Bailout.
841828 return bailout ( current , workInProgress , nextProps , null , renderPriority ) ;
@@ -1271,7 +1258,6 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
12711258 return resetToCurrent ( current , workInProgress , renderPriority ) ;
12721259 }
12731260
1274-
12751261 function beginWork (
12761262 current : Fiber | null ,
12771263 workInProgress : Fiber ,
@@ -1288,31 +1274,40 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
12881274 workInProgress . firstEffect = null ;
12891275 workInProgress . lastEffect = null ;
12901276
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+
12911284 switch ( workInProgress . tag ) {
12921285 case HostRoot :
1293- return beginHostRoot ( current , workInProgress , renderPriority ) ;
1286+ return beginHostRoot ( current , workInProgress , nextProps , renderPriority ) ;
12941287 case HostPortal :
1295- return beginHostPortal ( current , workInProgress , renderPriority ) ;
1288+ return beginHostPortal ( current , workInProgress , nextProps , renderPriority ) ;
12961289 case HostComponent :
1297- return beginHostComponent ( current , workInProgress , renderPriority ) ;
1290+ return beginHostComponent ( current , workInProgress , nextProps , renderPriority ) ;
12981291 case HostText :
1299- return beginHostText ( current , workInProgress , renderPriority ) ;
1292+ return beginHostText ( current , workInProgress , nextProps , renderPriority ) ;
13001293 case IndeterminateComponent :
13011294 return beginIndeterminateComponent (
13021295 current ,
13031296 workInProgress ,
1297+ nextProps ,
13041298 renderPriority ,
13051299 ) ;
13061300 case FunctionalComponent :
13071301 return beginFunctionalComponent (
13081302 current ,
13091303 workInProgress ,
1304+ nextProps ,
13101305 renderPriority ,
13111306 ) ;
13121307 case ClassComponent :
1313- return beginClassComponent ( current , workInProgress , renderPriority ) ;
1308+ return beginClassComponent ( current , workInProgress , nextProps , renderPriority ) ;
13141309 case Fragment :
1315- return beginFragment ( current , workInProgress , renderPriority ) ;
1310+ return beginFragment ( current , workInProgress , nextProps , renderPriority ) ;
13161311 default :
13171312 invariant (
13181313 false ,
0 commit comments