MCPcopy Create free account
hub / github.com/BetaSu/big-react / performConcurrentWorkOnRoot

Function performConcurrentWorkOnRoot

packages/react-reconciler/src/workLoop.ts:172–218  ·  view source on GitHub ↗
(
	root: FiberRootNode,
	didTimeout: boolean
)

Source from the content-addressed store, hash-verified

170}
171
172function performConcurrentWorkOnRoot(
173 root: FiberRootNode,
174 didTimeout: boolean
175): any {
176 // 保证useEffect回调执行
177 const curCallback = root.callbackNode;
178 const didFlushPassiveEffect = flushPassiveEffects(root.pendingPassiveEffects);
179 if (didFlushPassiveEffect) {
180 if (root.callbackNode !== curCallback) {
181 return null;
182 }
183 }
184
185 const lane = getNextLane(root);
186 const curCallbackNode = root.callbackNode;
187 if (lane === NoLane) {
188 return null;
189 }
190 const needSync = lane === SyncLane || didTimeout;
191 // render阶段
192 const exitStatus = renderRoot(root, lane, !needSync);
193
194 switch (exitStatus) {
195 // 中断
196 case RootInComplete:
197 if (root.callbackNode !== curCallbackNode) {
198 return null;
199 }
200 return performConcurrentWorkOnRoot.bind(null, root);
201 case RootCompleted:
202 const finishedWork = root.current.alternate;
203 root.finishedWork = finishedWork;
204 root.finishedLane = lane;
205 wipRootRenderLane = NoLane;
206 commitRoot(root);
207 break;
208 case RootDidNotComplete:
209 markRootSuspended(root, lane);
210 wipRootRenderLane = NoLane;
211 ensureRootIsScheduled(root);
212 break;
213 default:
214 if (__DEV__) {
215 console.error('还未实现的并发更新结束状态');
216 }
217 }
218}
219
220function performSyncWorkOnRoot(root: FiberRootNode) {
221 const nextLane = getNextLane(root);

Callers

nothing calls this directly

Calls 6

getNextLaneFunction · 0.90
markRootSuspendedFunction · 0.90
flushPassiveEffectsFunction · 0.85
renderRootFunction · 0.85
commitRootFunction · 0.85
ensureRootIsScheduledFunction · 0.85

Tested by

no test coverage detected