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

Function commitNestedComponent

packages/react-reconciler/src/commitWork.ts:400–428  ·  view source on GitHub ↗
(
	root: FiberNode,
	onCommitUnmount: (fiber: FiberNode) => void
)

Source from the content-addressed store, hash-verified

398}
399
400function commitNestedComponent(
401 root: FiberNode,
402 onCommitUnmount: (fiber: FiberNode) => void
403) {
404 let node = root;
405 while (true) {
406 onCommitUnmount(node);
407
408 if (node.child !== null) {
409 // 向下遍历
410 node.child.return = node;
411 node = node.child;
412 continue;
413 }
414 if (node === root) {
415 // 终止条件
416 return;
417 }
418 while (node.sibling === null) {
419 if (node.return === null || node.return === root) {
420 return;
421 }
422 // 向上归
423 node = node.return;
424 }
425 node.sibling.return = node.return;
426 node = node.sibling;
427 }
428}
429
430const commitPlacement = (finishedWork: FiberNode) => {
431 if (__DEV__) {

Callers 1

commitDeletionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected