if (next !== null) { workInProgress = next; return; } } else { var _next = unwindWork(completedWork, subtreeRenderLanes); // Because this fiber did not complete, don't reset its expiration time.
if ( (completedWork.mode & ProfileMode) !== NoMode) { stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); // Include the time spent working on failed children before continuing.
var actualDuration = completedWork.actualDuration; var child = completedWork.child;
if (siblingFiber !== null) { // If there is more work to do in this returnFiber, do that next. workInProgress = siblingFiber; return; } // Otherwise, return to the parent
completedWork = returnFiber; // Update the next thing we're working on in case something throws.
workInProgress = completedWork; } while (completedWork !== null); // We've reached the root.
if (workInProgressRootExitStatus === RootIncomplete) { workInProgressRootExitStatus = RootCompleted; } }
switch (workInProgress.tag) { case IndeterminateComponent: case LazyComponent: case SimpleMemoComponent: case FunctionComponent: case ForwardRef: case Fragment: case Mode: case Profiler: case ContextConsumer: case MemoComponent: bubbleProperties(workInProgress); returnnull;
case ClassComponent: { var Component = workInProgress.type;
if (isContextProvider(Component)) { popContext(workInProgress); }
bubbleProperties(workInProgress); returnnull; }
case HostComponent: { popHostContext(workInProgress); var rootContainerInstance = getRootHostContainer(); var type = workInProgress.type;
if (current.ref !== workInProgress.ref) { markRef$1(workInProgress); } } else { if (!newProps) { if (!(workInProgress.stateNode !== null)) { { throwError( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); } } // This can happen when we abort work.
bubbleProperties(workInProgress); returnnull; }
var currentHostContext = getHostContext(); // TODO: Move createInstance to beginWork and keep it on a context // "stack" as the parent. Then append children as we go in beginWork // or completeWork depending on whether we want to add them top->down or // bottom->up. Top->down is faster in IE11.
var _wasHydrated = popHydrationState(workInProgress);
if (_wasHydrated) { // TODO: Move this and createInstance step into the beginPhase // to consolidate. if (prepareToHydrateHostInstance(workInProgress, rootContainerInstance, currentHostContext)) { // If changes to the hydrated node need to be applied at the // commit-phase we mark this as such. markUpdate(workInProgress); } } else { var instance = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress); appendAllChildren(instance, workInProgress, false, false); workInProgress.stateNode = instance; // Certain renderers require commit-time effects for initial mount. // (eg DOM renderer supports auto-focus for certain elements). // Make sure such renderers get scheduled for later work.
if (finalizeInitialChildren(instance, type, newProps, rootContainerInstance)) { markUpdate(workInProgress); } }
if (workInProgress.ref !== null) { // If there is a ref on a host node we need to schedule a callback markRef$1(workInProgress); } }
if (current.ref !== workInProgress.ref) { markRef$1(workInProgress); } } else { if (!newProps) { // 如果没有新的props并且stateNode为null, 可能是React发生了内部错误, 挂载时newProps至少也是一个{}, 一定不会进这里 if (!(workInProgress.stateNode !== null)) { { throwError( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); } } // This can happen when we abort work. bubbleProperties(workInProgress); returnnull; }
var currentHostContext = getHostContext(); // context相关 var _wasHydrated = popHydrationState(workInProgress); // 服务端渲染相关
if (_wasHydrated) {// 服务端渲染 if (prepareToHydrateHostInstance(workInProgress, rootContainerInstance, currentHostContext)) { markUpdate(workInProgress); } } else { var instance = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress); appendAllChildren(instance, workInProgress, false, false); workInProgress.stateNode = instance; // Certain renderers require commit-time effects for initial mount. // (eg DOM renderer supports auto-focus for certain elements). // Make sure such renderers get scheduled for later work.
if (finalizeInitialChildren(instance, type, newProps, rootContainerInstance)) { markUpdate(workInProgress); } }
if (workInProgress.ref !== null) { // If there is a ref on a host node we need to schedule a callback markRef$1(workInProgress); } }
default: if (typeof props.onClick === 'function') { // TODO: This cast may not be sound for SVG, MathML or custom elements. trapClickOnNonInteractiveElement(domElement); }
if ( (completedWork.mode & ProfileMode) !== NoMode) { var actualDuration = completedWork.actualDuration; var treeBaseDuration = completedWork.selfBaseDuration; var child = completedWork.child;
for (styleName in nextProp) { if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) { if (!styleUpdates) { styleUpdates = {}; }
styleUpdates[styleName] = nextProp[styleName]; } } } else { if (!styleUpdates) { if (!updatePayload) { updatePayload = []; }