@@ -18,7 +18,7 @@ import type { FiberRoot } from 'ReactFiberRoot';
1818import type { HostConfig } from 'ReactFiberReconciler' ;
1919import type { Scheduler } from 'ReactFiberScheduler' ;
2020import type { PriorityLevel } from 'ReactPriorityLevel' ;
21- import type { StateQueue } from 'ReactFiberStateQueue ' ;
21+ import type { UpdateQueue } from 'ReactFiberUpdateQueue ' ;
2222
2323var {
2424 reconcileChildFibers,
@@ -42,10 +42,10 @@ var {
4242} = require ( 'ReactPriorityLevel' ) ;
4343var { findNextUnitOfWorkAtPriority } = require ( 'ReactFiberPendingWork' ) ;
4444var {
45- createStateQueue ,
45+ createUpdateQueue ,
4646 addToQueue,
47- mergeStateQueue ,
48- } = require ( 'ReactFiberStateQueue ' ) ;
47+ mergeUpdateQueue ,
48+ } = require ( 'ReactFiberUpdateQueue ' ) ;
4949var ReactInstanceMap = require ( 'ReactInstanceMap' ) ;
5050
5151module . exports = function < T , P , I , C > ( config : HostConfig < T , P , I , C > , getScheduler : ( ) = > Scheduler ) {
@@ -89,15 +89,15 @@ module.exports = function<T, P, I, C>(config : HostConfig<T, P, I, C>, getSchedu
8989 workInProgress . pendingWorkPriority = NoWork ;
9090 }
9191
92- function scheduleUpdate ( fiber : Fiber , stateQueue : StateQueue , priorityLevel : PriorityLevel ) : void {
92+ function scheduleUpdate ( fiber : Fiber , updateQueue : UpdateQueue , priorityLevel : PriorityLevel ) : void {
9393 const { scheduleLowPriWork } = getScheduler ( ) ;
94- fiber . stateQueue = stateQueue ;
94+ fiber . updateQueue = updateQueue ;
9595 // Schedule update on the alternate as well, since we don't know which tree
9696 // is current.
9797 // $FlowFixMe: Intersection issue. Don't know why it's only happening here.
9898 const { alternate } = fiber ;
9999 if ( alternate !== null ) {
100- alternate . stateQueue = stateQueue ;
100+ alternate . updateQueue = updateQueue ;
101101 }
102102 while ( true ) {
103103 if ( fiber . pendingWorkPriority === NoWork ||
@@ -127,10 +127,10 @@ module.exports = function<T, P, I, C>(config : HostConfig<T, P, I, C>, getSchedu
127127 const updater = {
128128 enqueueSetState ( instance , partialState ) {
129129 const fiber = ReactInstanceMap . get ( instance ) ;
130- const stateQueue = fiber . stateQueue ?
131- addToQueue ( fiber . stateQueue , partialState ) :
132- createStateQueue ( partialState ) ;
133- scheduleUpdate ( fiber , stateQueue , LowPriority ) ;
130+ const updateQueue = fiber . updateQueue ?
131+ addToQueue ( fiber . updateQueue , partialState ) :
132+ createUpdateQueue ( partialState ) ;
133+ scheduleUpdate ( fiber , updateQueue , LowPriority ) ;
134134 } ,
135135 } ;
136136
@@ -142,21 +142,22 @@ module.exports = function<T, P, I, C>(config : HostConfig<T, P, I, C>, getSchedu
142142 if ( ! props && current ) {
143143 props = current . memoizedProps ;
144144 }
145- // Compute the state using the memoized state and the pending state queue.
146- var stateQueue = workInProgress . stateQueue ;
147- var state = current ?
148- mergeStateQueue ( stateQueue , current . memoizedState , props ) :
149- mergeStateQueue ( stateQueue , null , props ) ;
145+ // Compute the state using the memoized state and the update queue.
146+ var updateQueue = workInProgress . updateQueue ;
147+ var previousState = current ? current . memoizedState : null ;
148+ var state = updateQueue ?
149+ mergeUpdateQueue ( updateQueue , previousState , props ) :
150+ previousState ;
150151
151152 var instance = workInProgress . stateNode ;
152153 if ( ! instance ) {
153154 var ctor = workInProgress . type ;
154155 workInProgress . stateNode = instance = new ctor ( props ) ;
155156 state = instance . state || null ;
156- // The initial state must be added to the pending state queue in case
157+ // The initial state must be added to the update queue in case
157158 // setState is called before the initial render.
158159 if ( state !== null ) {
159- workInProgress . stateQueue = createStateQueue ( state ) ;
160+ workInProgress . updateQueue = createUpdateQueue ( state ) ;
160161 }
161162 // The instance needs access to the fiber so that it can schedule updates
162163 ReactInstanceMap . set ( instance , workInProgress ) ;
@@ -290,7 +291,7 @@ module.exports = function<T, P, I, C>(config : HostConfig<T, P, I, C>, getSchedu
290291 workInProgress . output = current . output ;
291292 const priorityLevel = workInProgress . pendingWorkPriority ;
292293 workInProgress . pendingProps = null ;
293- workInProgress . stateQueue = current . stateQueue = null ;
294+ workInProgress . updateQueue = current . updateQueue = null ;
294295 workInProgress . pendingWorkPriority = NoWork ;
295296 workInProgress . stateNode = current . stateNode ;
296297 workInProgress . childInProgress = current . childInProgress ;
@@ -320,9 +321,9 @@ module.exports = function<T, P, I, C>(config : HostConfig<T, P, I, C>, getSchedu
320321 // looking for. In that case, we should be able to just bail out.
321322 const priorityLevel = workInProgress . pendingWorkPriority ;
322323 workInProgress . pendingProps = null ;
323- workInProgress . stateQueue = null ;
324+ workInProgress . updateQueue = null ;
324325 if ( workInProgress . alternate ) {
325- workInProgress . alternate . stateQueue = null ;
326+ workInProgress . alternate . updateQueue = null ;
326327 }
327328 workInProgress . pendingWorkPriority = NoWork ;
328329
@@ -365,14 +366,14 @@ module.exports = function<T, P, I, C>(config : HostConfig<T, P, I, C>, getSchedu
365366 // progress.
366367 if ( current &&
367368 workInProgress . pendingProps === current . memoizedProps &&
368- workInProgress . stateQueue === null
369+ workInProgress . updateQueue === null
369370 ) {
370371 return bailoutOnCurrent ( current , workInProgress , null ) ;
371372 }
372373
373374 if ( ! workInProgress . childInProgress &&
374375 workInProgress . pendingProps === workInProgress . memoizedProps &&
375- workInProgress . stateQueue === null
376+ workInProgress . updateQueue === null
376377 ) {
377378 return bailoutOnAlreadyFinishedWork ( current , workInProgress ) ;
378379 }
0 commit comments