@@ -51,6 +51,18 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
5151 const createTextInstance = config . createTextInstance ;
5252 const prepareUpdate = config . prepareUpdate ;
5353
54+ function markChildAsProgressed ( current , workInProgress , priorityLevel ) {
55+ // We now have clones. Let's store them as the currently progressed work.
56+ workInProgress . progressedChild = workInProgress . child ;
57+ workInProgress . progressedPriority = priorityLevel ;
58+ if ( current ) {
59+ // We also store it on the current. When the alternate swaps in we can
60+ // continue from this point.
61+ current . progressedChild = workInProgress . progressedChild ;
62+ current . progressedPriority = workInProgress . progressedPriority ;
63+ }
64+ }
65+
5466 function markUpdate ( workInProgress : Fiber ) {
5567 // Tag the fiber with an update effect. This turns a Placement into
5668 // an UpdateAndPlacement.
@@ -63,15 +75,14 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
6375 }
6476
6577 function appendAllYields ( yields : Array < ReifiedYield > , workInProgress : Fiber ) {
66- let node = workInProgress . child ;
78+ let node = workInProgress . stateNode ;
6779 while ( node ) {
6880 if ( node . tag === HostComponent || node . tag === HostText ||
6981 node . tag === Portal ) {
7082 throw new Error ( 'A coroutine cannot have host component children.' ) ;
7183 } else if ( node . tag === YieldComponent ) {
7284 yields . push ( node . type ) ;
7385 } else if ( node . child ) {
74- // TODO: Coroutines need to visit the stateNode.
7586 node . child . return = node ;
7687 node = node . child ;
7788 continue ;
@@ -113,16 +124,17 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
113124 var props = coroutine.props;
114125 var nextChildren = fn(props, yields);
115126
116- var currentFirstChild = current ? current.stateNode : null;
127+ var currentFirstChild = current ? current.child : null;
117128 // Inherit the priority of the returnFiber.
118129 const priority = workInProgress.pendingWorkPriority;
119- workInProgress.stateNode = reconcileChildFibers(
130+ workInProgress.child = reconcileChildFibers(
120131 workInProgress,
121132 currentFirstChild,
122133 nextChildren,
123134 priority
124135 );
125- return workInProgress.stateNode;
136+ markChildAsProgressed(current, workInProgress, priority);
137+ return workInProgress.child;
126138 }
127139
128140 function appendAllChildren ( parent : I , workInProgress : Fiber ) {
@@ -137,7 +149,6 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
137149 // down its children. Instead, we'll get insertions from each child in
138150 // the portal directly.
139151 } else if ( node . child ) {
140- // TODO: Coroutines need to visit the stateNode.
141152 node = node . child ;
142153 continue ;
143154 }
0 commit comments