function commitLayoutEffects()

in Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js [6239:6433]


function commitLayoutEffects(finishedWork, root, committedLanes) {
  inProgressLanes = committedLanes;
  inProgressRoot = root;
  for (nextEffect = finishedWork; null !== nextEffect; )
    if (
      ((root = nextEffect),
      (committedLanes = root.child),
      0 !== (root.subtreeFlags & 324) && null !== committedLanes)
    )
      (committedLanes.return = root), (nextEffect = committedLanes);
    else
      for (root = finishedWork; null !== nextEffect; ) {
        committedLanes = nextEffect;
        if (0 !== (committedLanes.flags & 324)) {
          var current = committedLanes.alternate;
          try {
            if (0 !== (committedLanes.flags & 68))
              switch (committedLanes.tag) {
                case 0:
                case 11:
                case 15:
                  if (committedLanes.mode & 2)
                    try {
                      startLayoutEffectTimer(),
                        commitHookEffectListMount(3, committedLanes);
                    } finally {
                      recordLayoutEffectDuration(committedLanes);
                    }
                  else commitHookEffectListMount(3, committedLanes);
                  break;
                case 1:
                  var instance = committedLanes.stateNode;
                  if (committedLanes.flags & 4)
                    if (null === current)
                      if (committedLanes.mode & 2)
                        try {
                          startLayoutEffectTimer(),
                            instance.componentDidMount();
                        } finally {
                          recordLayoutEffectDuration(committedLanes);
                        }
                      else instance.componentDidMount();
                    else {
                      var prevProps =
                          committedLanes.elementType === committedLanes.type
                            ? current.memoizedProps
                            : resolveDefaultProps(
                                committedLanes.type,
                                current.memoizedProps
                              ),
                        prevState = current.memoizedState;
                      if (committedLanes.mode & 2)
                        try {
                          startLayoutEffectTimer(),
                            instance.componentDidUpdate(
                              prevProps,
                              prevState,
                              instance.__reactInternalSnapshotBeforeUpdate
                            );
                        } finally {
                          recordLayoutEffectDuration(committedLanes);
                        }
                      else
                        instance.componentDidUpdate(
                          prevProps,
                          prevState,
                          instance.__reactInternalSnapshotBeforeUpdate
                        );
                    }
                  var updateQueue = committedLanes.updateQueue;
                  null !== updateQueue &&
                    commitUpdateQueue(committedLanes, updateQueue, instance);
                  break;
                case 3:
                  var updateQueue$90 = committedLanes.updateQueue;
                  if (null !== updateQueue$90) {
                    var instance$91 = null;
                    if (null !== committedLanes.child)
                      switch (committedLanes.child.tag) {
                        case 5:
                          instance$91 = committedLanes.child.stateNode;
                          break;
                        case 1:
                          instance$91 = committedLanes.child.stateNode;
                      }
                    commitUpdateQueue(
                      committedLanes,
                      updateQueue$90,
                      instance$91
                    );
                  }
                  break;
                case 5:
                  break;
                case 6:
                  break;
                case 4:
                  break;
                case 12:
                  var _finishedWork$memoize2 = committedLanes.memoizedProps,
                    onCommit = _finishedWork$memoize2.onCommit,
                    onRender = _finishedWork$memoize2.onRender,
                    effectDuration = committedLanes.stateNode.effectDuration;
                  instance$91 = commitTime;
                  current = null === current ? "mount" : "update";
                  currentUpdateIsNested && (current = "nested-update");
                  "function" === typeof onRender &&
                    onRender(
                      committedLanes.memoizedProps.id,
                      current,
                      committedLanes.actualDuration,
                      committedLanes.treeBaseDuration,
                      committedLanes.actualStartTime,
                      instance$91
                    );
                  "function" === typeof onCommit &&
                    onCommit(
                      committedLanes.memoizedProps.id,
                      current,
                      effectDuration,
                      instance$91
                    );
                  enqueuePendingPassiveProfilerEffect(committedLanes);
                  var parentFiber = committedLanes.return;
                  a: for (; null !== parentFiber; ) {
                    switch (parentFiber.tag) {
                      case 3:
                        parentFiber.stateNode.effectDuration += effectDuration;
                        break a;
                      case 12:
                        parentFiber.stateNode.effectDuration += effectDuration;
                        break a;
                    }
                    parentFiber = parentFiber.return;
                  }
                  break;
                case 13:
                  break;
                case 19:
                case 17:
                case 21:
                case 22:
                case 23:
                  break;
                default:
                  throw Error(
                    "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."
                  );
              }
            if (committedLanes.flags & 256) {
              instance$91 = void 0;
              current = committedLanes;
              var ref = current.ref;
              if (null !== ref) {
                var instance$jscomp$0 = current.stateNode;
                switch (current.tag) {
                  case 5:
                    instance$91 = instance$jscomp$0;
                    break;
                  default:
                    instance$91 = instance$jscomp$0;
                }
                if ("function" === typeof ref)
                  if (current.mode & 2)
                    try {
                      startLayoutEffectTimer(), ref(instance$91);
                    } finally {
                      recordLayoutEffectDuration(current);
                    }
                  else ref(instance$91);
                else ref.current = instance$91;
              }
            }
          } catch (error) {
            captureCommitPhaseError(
              committedLanes,
              committedLanes.return,
              error
            );
          }
        }
        if (committedLanes === root) {
          nextEffect = null;
          break;
        }
        instance$91 = committedLanes.sibling;
        if (null !== instance$91) {
          instance$91.return = committedLanes.return;
          nextEffect = instance$91;
          break;
        }
        nextEffect = committedLanes.return;
      }
  inProgressRoot = inProgressLanes = null;
}