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

Function commitEffects

packages/react-reconciler/src/commitWork.ts:40–68  ·  view source on GitHub ↗
(
	phrase: 'mutation' | 'layout',
	mask: Flags,
	callback: (fiber: FiberNode, root: FiberRootNode) => void
)

Source from the content-addressed store, hash-verified

38let nextEffect: FiberNode | null = null;
39
40export const commitEffects = (
41 phrase: 'mutation' | 'layout',
42 mask: Flags,
43 callback: (fiber: FiberNode, root: FiberRootNode) => void
44) => {
45 return (finishedWork: FiberNode, root: FiberRootNode) => {
46 nextEffect = finishedWork;
47 while (nextEffect !== null) {
48 // 向下遍历
49 const child: FiberNode | null = nextEffect.child;
50
51 if ((nextEffect.subtreeFlags & mask) !== NoFlags && child !== null) {
52 nextEffect = child;
53 } else {
54 // 向上遍历 DFS
55 up: while (nextEffect !== null) {
56 callback(nextEffect, root);
57 const sibling: FiberNode | null = nextEffect.sibling;
58
59 if (sibling !== null) {
60 nextEffect = sibling;
61 break up;
62 }
63 nextEffect = nextEffect.return;
64 }
65 }
66 }
67 };
68};
69
70const commitMutationEffectsOnFiber = (
71 finishedWork: FiberNode,

Callers 1

commitWork.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected