beginWork$1 = function()

in Libraries/Renderer/implementations/ReactFabric-profiling.js [7347:7862]


beginWork$1 = function(current, workInProgress, renderLanes) {
  var updateLanes = workInProgress.lanes;
  if (null !== current)
    if (
      current.memoizedProps !== workInProgress.pendingProps ||
      didPerformWorkStackCursor.current
    )
      didReceiveUpdate = !0;
    else {
      if (0 === (renderLanes & updateLanes)) {
        didReceiveUpdate = !1;
        switch (workInProgress.tag) {
          case 3:
            pushHostRootContext(workInProgress);
            break;
          case 5:
            pushHostContext(workInProgress);
            break;
          case 1:
            isContextProvider(workInProgress.type) &&
              pushContextProvider(workInProgress);
            break;
          case 4:
            pushHostContainer(
              workInProgress,
              workInProgress.stateNode.containerInfo
            );
            break;
          case 10:
            updateLanes = workInProgress.type._context;
            var nextValue = workInProgress.memoizedProps.value;
            push(valueCursor, updateLanes._currentValue2);
            updateLanes._currentValue2 = nextValue;
            break;
          case 12:
            0 !== (renderLanes & workInProgress.childLanes) &&
              (workInProgress.flags |= 4);
            updateLanes = workInProgress.stateNode;
            updateLanes.effectDuration = 0;
            updateLanes.passiveEffectDuration = 0;
            break;
          case 13:
            if (null !== workInProgress.memoizedState) {
              if (0 !== (renderLanes & workInProgress.child.childLanes))
                return updateSuspenseComponent(
                  current,
                  workInProgress,
                  renderLanes
                );
              push(suspenseStackCursor, suspenseStackCursor.current & 1);
              workInProgress = bailoutOnAlreadyFinishedWork(
                current,
                workInProgress,
                renderLanes
              );
              return null !== workInProgress ? workInProgress.sibling : null;
            }
            push(suspenseStackCursor, suspenseStackCursor.current & 1);
            break;
          case 19:
            updateLanes = 0 !== (renderLanes & workInProgress.childLanes);
            if (0 !== (current.flags & 128)) {
              if (updateLanes)
                return updateSuspenseListComponent(
                  current,
                  workInProgress,
                  renderLanes
                );
              workInProgress.flags |= 128;
            }
            nextValue = workInProgress.memoizedState;
            null !== nextValue &&
              ((nextValue.rendering = null),
              (nextValue.tail = null),
              (nextValue.lastEffect = null));
            push(suspenseStackCursor, suspenseStackCursor.current);
            if (updateLanes) break;
            else return null;
          case 22:
          case 23:
            return (
              (workInProgress.lanes = 0),
              updateOffscreenComponent(current, workInProgress, renderLanes)
            );
        }
        return bailoutOnAlreadyFinishedWork(
          current,
          workInProgress,
          renderLanes
        );
      }
      didReceiveUpdate = 0 !== (current.flags & 32768) ? !0 : !1;
    }
  else didReceiveUpdate = !1;
  workInProgress.lanes = 0;
  switch (workInProgress.tag) {
    case 2:
      updateLanes = workInProgress.type;
      null !== current &&
        ((current.alternate = null),
        (workInProgress.alternate = null),
        (workInProgress.flags |= 2));
      current = workInProgress.pendingProps;
      nextValue = getMaskedContext(workInProgress, contextStackCursor.current);
      prepareToReadContext(workInProgress, renderLanes);
      nextValue = renderWithHooks(
        null,
        workInProgress,
        updateLanes,
        current,
        nextValue,
        renderLanes
      );
      workInProgress.flags |= 1;
      if (
        "object" === typeof nextValue &&
        null !== nextValue &&
        "function" === typeof nextValue.render &&
        void 0 === nextValue.$$typeof
      ) {
        workInProgress.tag = 1;
        workInProgress.memoizedState = null;
        workInProgress.updateQueue = null;
        if (isContextProvider(updateLanes)) {
          var hasContext = !0;
          pushContextProvider(workInProgress);
        } else hasContext = !1;
        workInProgress.memoizedState =
          null !== nextValue.state && void 0 !== nextValue.state
            ? nextValue.state
            : null;
        initializeUpdateQueue(workInProgress);
        nextValue.updater = classComponentUpdater;
        workInProgress.stateNode = nextValue;
        nextValue._reactInternals = workInProgress;
        mountClassInstance(workInProgress, updateLanes, current, renderLanes);
        workInProgress = finishClassComponent(
          null,
          workInProgress,
          updateLanes,
          !0,
          hasContext,
          renderLanes
        );
      } else
        (workInProgress.tag = 0),
          reconcileChildren(null, workInProgress, nextValue, renderLanes),
          (workInProgress = workInProgress.child);
      return workInProgress;
    case 16:
      nextValue = workInProgress.elementType;
      a: {
        null !== current &&
          ((current.alternate = null),
          (workInProgress.alternate = null),
          (workInProgress.flags |= 2));
        current = workInProgress.pendingProps;
        hasContext = nextValue._init;
        nextValue = hasContext(nextValue._payload);
        workInProgress.type = nextValue;
        hasContext = workInProgress.tag = resolveLazyComponentTag(nextValue);
        current = resolveDefaultProps(nextValue, current);
        switch (hasContext) {
          case 0:
            workInProgress = updateFunctionComponent(
              null,
              workInProgress,
              nextValue,
              current,
              renderLanes
            );
            break a;
          case 1:
            workInProgress = updateClassComponent(
              null,
              workInProgress,
              nextValue,
              current,
              renderLanes
            );
            break a;
          case 11:
            workInProgress = updateForwardRef(
              null,
              workInProgress,
              nextValue,
              current,
              renderLanes
            );
            break a;
          case 14:
            workInProgress = updateMemoComponent(
              null,
              workInProgress,
              nextValue,
              resolveDefaultProps(nextValue.type, current),
              updateLanes,
              renderLanes
            );
            break a;
        }
        throw Error(
          "Element type is invalid. Received a promise that resolves to: " +
            nextValue +
            ". Lazy element type must resolve to a class or function."
        );
      }
      return workInProgress;
    case 0:
      return (
        (updateLanes = workInProgress.type),
        (nextValue = workInProgress.pendingProps),
        (nextValue =
          workInProgress.elementType === updateLanes
            ? nextValue
            : resolveDefaultProps(updateLanes, nextValue)),
        updateFunctionComponent(
          current,
          workInProgress,
          updateLanes,
          nextValue,
          renderLanes
        )
      );
    case 1:
      return (
        (updateLanes = workInProgress.type),
        (nextValue = workInProgress.pendingProps),
        (nextValue =
          workInProgress.elementType === updateLanes
            ? nextValue
            : resolveDefaultProps(updateLanes, nextValue)),
        updateClassComponent(
          current,
          workInProgress,
          updateLanes,
          nextValue,
          renderLanes
        )
      );
    case 3:
      pushHostRootContext(workInProgress);
      updateLanes = workInProgress.updateQueue;
      if (null === current || null === updateLanes)
        throw Error(
          "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue."
        );
      nextValue = workInProgress.pendingProps;
      updateLanes = workInProgress.memoizedState.element;
      cloneUpdateQueue(current, workInProgress);
      processUpdateQueue(workInProgress, nextValue, null, renderLanes);
      nextValue = workInProgress.memoizedState.element;
      nextValue === updateLanes
        ? (workInProgress = bailoutOnAlreadyFinishedWork(
            current,
            workInProgress,
            renderLanes
          ))
        : (reconcileChildren(current, workInProgress, nextValue, renderLanes),
          (workInProgress = workInProgress.child));
      return workInProgress;
    case 5:
      return (
        pushHostContext(workInProgress),
        (updateLanes = workInProgress.pendingProps.children),
        markRef(current, workInProgress),
        reconcileChildren(current, workInProgress, updateLanes, renderLanes),
        workInProgress.child
      );
    case 6:
      return null;
    case 13:
      return updateSuspenseComponent(current, workInProgress, renderLanes);
    case 4:
      return (
        pushHostContainer(
          workInProgress,
          workInProgress.stateNode.containerInfo
        ),
        (updateLanes = workInProgress.pendingProps),
        null === current
          ? (workInProgress.child = reconcileChildFibers(
              workInProgress,
              null,
              updateLanes,
              renderLanes
            ))
          : reconcileChildren(
              current,
              workInProgress,
              updateLanes,
              renderLanes
            ),
        workInProgress.child
      );
    case 11:
      return (
        (updateLanes = workInProgress.type),
        (nextValue = workInProgress.pendingProps),
        (nextValue =
          workInProgress.elementType === updateLanes
            ? nextValue
            : resolveDefaultProps(updateLanes, nextValue)),
        updateForwardRef(
          current,
          workInProgress,
          updateLanes,
          nextValue,
          renderLanes
        )
      );
    case 7:
      return (
        reconcileChildren(
          current,
          workInProgress,
          workInProgress.pendingProps,
          renderLanes
        ),
        workInProgress.child
      );
    case 8:
      return (
        reconcileChildren(
          current,
          workInProgress,
          workInProgress.pendingProps.children,
          renderLanes
        ),
        workInProgress.child
      );
    case 12:
      return (
        (workInProgress.flags |= 4),
        (updateLanes = workInProgress.stateNode),
        (updateLanes.effectDuration = 0),
        (updateLanes.passiveEffectDuration = 0),
        reconcileChildren(
          current,
          workInProgress,
          workInProgress.pendingProps.children,
          renderLanes
        ),
        workInProgress.child
      );
    case 10:
      a: {
        updateLanes = workInProgress.type._context;
        nextValue = workInProgress.pendingProps;
        hasContext = workInProgress.memoizedProps;
        var newValue = nextValue.value;
        push(valueCursor, updateLanes._currentValue2);
        updateLanes._currentValue2 = newValue;
        if (null !== hasContext)
          if (objectIs(hasContext.value, newValue)) {
            if (
              hasContext.children === nextValue.children &&
              !didPerformWorkStackCursor.current
            ) {
              workInProgress = bailoutOnAlreadyFinishedWork(
                current,
                workInProgress,
                renderLanes
              );
              break a;
            }
          } else
            for (
              newValue = workInProgress.child,
                null !== newValue && (newValue.return = workInProgress);
              null !== newValue;

            ) {
              var list = newValue.dependencies;
              if (null !== list) {
                hasContext = newValue.child;
                for (
                  var dependency = list.firstContext;
                  null !== dependency;

                ) {
                  if (dependency.context === updateLanes) {
                    if (1 === newValue.tag) {
                      dependency = createUpdate(-1, renderLanes & -renderLanes);
                      dependency.tag = 2;
                      var updateQueue = newValue.updateQueue;
                      if (null !== updateQueue) {
                        updateQueue = updateQueue.shared;
                        var pending = updateQueue.pending;
                        null === pending
                          ? (dependency.next = dependency)
                          : ((dependency.next = pending.next),
                            (pending.next = dependency));
                        updateQueue.pending = dependency;
                      }
                    }
                    newValue.lanes |= renderLanes;
                    dependency = newValue.alternate;
                    null !== dependency && (dependency.lanes |= renderLanes);
                    scheduleWorkOnParentPath(newValue.return, renderLanes);
                    list.lanes |= renderLanes;
                    break;
                  }
                  dependency = dependency.next;
                }
              } else
                hasContext =
                  10 === newValue.tag
                    ? newValue.type === workInProgress.type
                      ? null
                      : newValue.child
                    : newValue.child;
              if (null !== hasContext) hasContext.return = newValue;
              else
                for (hasContext = newValue; null !== hasContext; ) {
                  if (hasContext === workInProgress) {
                    hasContext = null;
                    break;
                  }
                  newValue = hasContext.sibling;
                  if (null !== newValue) {
                    newValue.return = hasContext.return;
                    hasContext = newValue;
                    break;
                  }
                  hasContext = hasContext.return;
                }
              newValue = hasContext;
            }
        reconcileChildren(
          current,
          workInProgress,
          nextValue.children,
          renderLanes
        );
        workInProgress = workInProgress.child;
      }
      return workInProgress;
    case 9:
      return (
        (nextValue = workInProgress.type),
        (updateLanes = workInProgress.pendingProps.children),
        prepareToReadContext(workInProgress, renderLanes),
        (nextValue = readContext(nextValue)),
        (updateLanes = updateLanes(nextValue)),
        (workInProgress.flags |= 1),
        reconcileChildren(current, workInProgress, updateLanes, renderLanes),
        workInProgress.child
      );
    case 14:
      return (
        (nextValue = workInProgress.type),
        (hasContext = resolveDefaultProps(
          nextValue,
          workInProgress.pendingProps
        )),
        (hasContext = resolveDefaultProps(nextValue.type, hasContext)),
        updateMemoComponent(
          current,
          workInProgress,
          nextValue,
          hasContext,
          updateLanes,
          renderLanes
        )
      );
    case 15:
      return updateSimpleMemoComponent(
        current,
        workInProgress,
        workInProgress.type,
        workInProgress.pendingProps,
        updateLanes,
        renderLanes
      );
    case 17:
      return (
        (updateLanes = workInProgress.type),
        (nextValue = workInProgress.pendingProps),
        (nextValue =
          workInProgress.elementType === updateLanes
            ? nextValue
            : resolveDefaultProps(updateLanes, nextValue)),
        null !== current &&
          ((current.alternate = null),
          (workInProgress.alternate = null),
          (workInProgress.flags |= 2)),
        (workInProgress.tag = 1),
        isContextProvider(updateLanes)
          ? ((current = !0), pushContextProvider(workInProgress))
          : (current = !1),
        prepareToReadContext(workInProgress, renderLanes),
        constructClassInstance(workInProgress, updateLanes, nextValue),
        mountClassInstance(workInProgress, updateLanes, nextValue, renderLanes),
        finishClassComponent(
          null,
          workInProgress,
          updateLanes,
          !0,
          current,
          renderLanes
        )
      );
    case 19:
      return updateSuspenseListComponent(current, workInProgress, renderLanes);
    case 22:
      return updateOffscreenComponent(current, workInProgress, renderLanes);
    case 23:
      return updateOffscreenComponent(current, workInProgress, renderLanes);
  }
  throw Error(
    "Unknown unit of work tag (" +
      workInProgress.tag +
      "). This error is likely caused by a bug in React. Please file an issue."
  );
};