MCPcopy Create free account
hub / github.com/danielstocks/react-sortable / ReactFiberBeginWork

Function ReactFiberBeginWork

bundle.js:7351–7487  ·  view source on GitHub ↗
(config,hostContext,hydrationContext,scheduleUpdate,getPriorityContext)

Source from the content-addressed store, hash-verified

7349// if shouldComponentUpdate returns false.
7350instance.props=newProps;instance.state=newState;instance.context=newContext;return shouldUpdate;}return{adoptClassInstance:adoptClassInstance,constructClassInstance:constructClassInstance,mountClassInstance:mountClassInstance,// resumeMountClassInstance,
7351updateClassInstance:updateClassInstance};};var mountChildFibersInPlace=ReactChildFiber.mountChildFibersInPlace;var reconcileChildFibers=ReactChildFiber.reconcileChildFibers;var reconcileChildFibersInPlace=ReactChildFiber.reconcileChildFibersInPlace;var cloneChildFibers=ReactChildFiber.cloneChildFibers;var beginUpdateQueue$1=ReactFiberUpdateQueue.beginUpdateQueue;var getMaskedContext$1=ReactFiberContext.getMaskedContext;var getUnmaskedContext$1=ReactFiberContext.getUnmaskedContext;var hasContextChanged$1=ReactFiberContext.hasContextChanged;var pushContextProvider$1=ReactFiberContext.pushContextProvider;var pushTopLevelContextObject$1=ReactFiberContext.pushTopLevelContextObject;var invalidateContextProvider$1=ReactFiberContext.invalidateContextProvider;var IndeterminateComponent$2=ReactTypeOfWork.IndeterminateComponent;var FunctionalComponent$1=ReactTypeOfWork.FunctionalComponent;var ClassComponent$6=ReactTypeOfWork.ClassComponent;var HostRoot$7=ReactTypeOfWork.HostRoot;var HostComponent$7=ReactTypeOfWork.HostComponent;var HostText$4=ReactTypeOfWork.HostText;var HostPortal$4=ReactTypeOfWork.HostPortal;var CoroutineComponent$1=ReactTypeOfWork.CoroutineComponent;var CoroutineHandlerPhase=ReactTypeOfWork.CoroutineHandlerPhase;var YieldComponent$2=ReactTypeOfWork.YieldComponent;var Fragment$2=ReactTypeOfWork.Fragment;var NoWork$3=ReactPriorityLevel.NoWork;var OffscreenPriority$1=ReactPriorityLevel.OffscreenPriority;var PerformedWork$1=ReactTypeOfSideEffect.PerformedWork;var Placement$2=ReactTypeOfSideEffect.Placement;var ContentReset$1=ReactTypeOfSideEffect.ContentReset;var Err$1=ReactTypeOfSideEffect.Err;var Ref$1=ReactTypeOfSideEffect.Ref;var ReactCurrentOwner$2=ReactGlobalSharedState_1.ReactCurrentOwner;{var ReactDebugCurrentFiber$4=ReactDebugCurrentFiber_1;var _require7=ReactDebugFiberPerf_1,cancelWorkTimer=_require7.cancelWorkTimer;var warning$23=require$$0;var warnedAboutStatelessRefs={};}var ReactFiberBeginWork=function ReactFiberBeginWork(config,hostContext,hydrationContext,scheduleUpdate,getPriorityContext){var shouldSetTextContent=config.shouldSetTextContent,useSyncScheduling=config.useSyncScheduling,shouldDeprioritizeSubtree=config.shouldDeprioritizeSubtree;var pushHostContext=hostContext.pushHostContext,pushHostContainer=hostContext.pushHostContainer;var enterHydrationState=hydrationContext.enterHydrationState,resetHydrationState=hydrationContext.resetHydrationState,tryToClaimNextHydratableInstance=hydrationContext.tryToClaimNextHydratableInstance;var _ReactFiberClassCompo=ReactFiberClassComponent(scheduleUpdate,getPriorityContext,memoizeProps,memoizeState),adoptClassInstance=_ReactFiberClassCompo.adoptClassInstance,constructClassInstance=_ReactFiberClassCompo.constructClassInstance,mountClassInstance=_ReactFiberClassCompo.mountClassInstance,updateClassInstance=_ReactFiberClassCompo.updateClassInstance;function reconcileChildren(current,workInProgress,nextChildren){var priorityLevel=workInProgress.pendingWorkPriority;reconcileChildrenAtPriority(current,workInProgress,nextChildren,priorityLevel);}function reconcileChildrenAtPriority(current,workInProgress,nextChildren,priorityLevel){if(current===null){// If this is a fresh new component that hasn't been rendered yet, we
7352// won't update its child set by applying minimal side-effects. Instead,
7353// we will add them all to the child before it gets rendered. That means
7354// we can optimize this reconciliation pass by not tracking side-effects.
7355workInProgress.child=mountChildFibersInPlace(workInProgress,workInProgress.child,nextChildren,priorityLevel);}else if(current.child===workInProgress.child){// If the current child is the same as the work in progress, it means that
7356// we haven't yet started any work on these children. Therefore, we use
7357// the clone algorithm to create a copy of all the current children.
7358// If we had any progressed work already, that is invalid at this point so
7359// let's throw it out.
7360workInProgress.child=reconcileChildFibers(workInProgress,workInProgress.child,nextChildren,priorityLevel);}else{// If, on the other hand, it is already using a clone, that means we've
7361// already begun some work on this tree and we can continue where we left
7362// off by reconciling against the existing children.
7363workInProgress.child=reconcileChildFibersInPlace(workInProgress,workInProgress.child,nextChildren,priorityLevel);}}function updateFragment(current,workInProgress){var nextChildren=workInProgress.pendingProps;if(hasContextChanged$1()){// Normally we can bail out on props equality but if context has changed
7364// we don't do the bailout and we have to reuse existing props instead.
7365if(nextChildren===null){nextChildren=workInProgress.memoizedProps;}}else if(nextChildren===null||workInProgress.memoizedProps===nextChildren){return bailoutOnAlreadyFinishedWork(current,workInProgress);}reconcileChildren(current,workInProgress,nextChildren);memoizeProps(workInProgress,nextChildren);return workInProgress.child;}function markRef(current,workInProgress){var ref=workInProgress.ref;if(ref!==null&&(!current||current.ref!==ref)){// Schedule a Ref effect
7366workInProgress.effectTag|=Ref$1;}}function updateFunctionalComponent(current,workInProgress){var fn=workInProgress.type;var nextProps=workInProgress.pendingProps;var memoizedProps=workInProgress.memoizedProps;if(hasContextChanged$1()){// Normally we can bail out on props equality but if context has changed
7367// we don't do the bailout and we have to reuse existing props instead.
7368if(nextProps===null){nextProps=memoizedProps;}}else{if(nextProps===null||memoizedProps===nextProps){return bailoutOnAlreadyFinishedWork(current,workInProgress);}// TODO: consider bringing fn.shouldComponentUpdate() back.
7369// It used to be here.
7370}var unmaskedContext=getUnmaskedContext$1(workInProgress);var context=getMaskedContext$1(workInProgress,unmaskedContext);var nextChildren;{ReactCurrentOwner$2.current=workInProgress;ReactDebugCurrentFiber$4.setCurrentFiber(workInProgress,'render');nextChildren=fn(nextProps,context);ReactDebugCurrentFiber$4.setCurrentFiber(workInProgress,null);}// React DevTools reads this flag.
7371workInProgress.effectTag|=PerformedWork$1;reconcileChildren(current,workInProgress,nextChildren);memoizeProps(workInProgress,nextProps);return workInProgress.child;}function updateClassComponent(current,workInProgress,priorityLevel){// Push context providers early to prevent context stack mismatches.
7372// During mounting we don't know the child context yet as the instance doesn't exist.
7373// We will invalidate the child context in finishClassComponent() right after rendering.
7374var hasContext=pushContextProvider$1(workInProgress);var shouldUpdate=void 0;if(current===null){if(!workInProgress.stateNode){// In the initial pass we might need to construct the instance.
7375constructClassInstance(workInProgress,workInProgress.pendingProps);mountClassInstance(workInProgress,priorityLevel);shouldUpdate=true;}else{invariant(false,'Resuming work not yet implemented.');// In a resume, we'll already have an instance we can reuse.
7376// shouldUpdate = resumeMountClassInstance(workInProgress, priorityLevel);
7377}}else{shouldUpdate=updateClassInstance(current,workInProgress,priorityLevel);}return finishClassComponent(current,workInProgress,shouldUpdate,hasContext);}function finishClassComponent(current,workInProgress,shouldUpdate,hasContext){// Refs should update even if shouldComponentUpdate returns false
7378markRef(current,workInProgress);if(!shouldUpdate){// Context providers should defer to sCU for rendering
7379if(hasContext){invalidateContextProvider$1(workInProgress,false);}return bailoutOnAlreadyFinishedWork(current,workInProgress);}var instance=workInProgress.stateNode;// Rerender
7380ReactCurrentOwner$2.current=workInProgress;var nextChildren=void 0;{ReactDebugCurrentFiber$4.setCurrentFiber(workInProgress,'render');nextChildren=instance.render();ReactDebugCurrentFiber$4.setCurrentFiber(workInProgress,null);}// React DevTools reads this flag.
7381workInProgress.effectTag|=PerformedWork$1;reconcileChildren(current,workInProgress,nextChildren);// Memoize props and state using the values we just used to render.
7382// TODO: Restructure so we never read values from the instance.
7383memoizeState(workInProgress,instance.state);memoizeProps(workInProgress,instance.props);// The context might have changed so we need to recalculate it.
7384if(hasContext){invalidateContextProvider$1(workInProgress,true);}return workInProgress.child;}function pushHostRootContext(workInProgress){var root=workInProgress.stateNode;if(root.pendingContext){pushTopLevelContextObject$1(workInProgress,root.pendingContext,root.pendingContext!==root.context);}else if(root.context){// Should always be set
7385pushTopLevelContextObject$1(workInProgress,root.context,false);}pushHostContainer(workInProgress,root.containerInfo);}function updateHostRoot(current,workInProgress,priorityLevel){pushHostRootContext(workInProgress);var updateQueue=workInProgress.updateQueue;if(updateQueue!==null){var prevState=workInProgress.memoizedState;var state=beginUpdateQueue$1(current,workInProgress,updateQueue,null,prevState,null,priorityLevel);if(prevState===state){// If the state is the same as before, that's a bailout because we had
7386// no work matching this priority.
7387resetHydrationState();return bailoutOnAlreadyFinishedWork(current,workInProgress);}var element=state.element;if((current===null||current.child===null)&&enterHydrationState(workInProgress)){// If we don't have any current children this might be the first pass.
7388// We always try to hydrate. If this isn't a hydration pass there won't
7389// be any children to hydrate which is effectively the same thing as
7390// not hydrating.
7391// This is a bit of a hack. We track the host root as a placement to
7392// know that we're currently in a mounting state. That way isMounted
7393// works as expected. We must reset this before committing.
7394// TODO: Delete this when we delete isMounted and findDOMNode.
7395workInProgress.effectTag|=Placement$2;// Ensure that children mount into this root without tracking
7396// side-effects. This ensures that we don't store Placement effects on
7397// nodes that will be hydrated.
7398workInProgress.child=mountChildFibersInPlace(workInProgress,workInProgress.child,element,priorityLevel);}else{// Otherwise reset hydration state in case we aborted and resumed another
7399// root.
7400resetHydrationState();reconcileChildren(current,workInProgress,element);}memoizeState(workInProgress,state);return workInProgress.child;}resetHydrationState();// If there is no update queue, that's a bailout because the root has no props.
7401return bailoutOnAlreadyFinishedWork(current,workInProgress);}function updateHostComponent(current,workInProgress,renderPriority){pushHostContext(workInProgress);if(current===null){tryToClaimNextHydratableInstance(workInProgress);}var type=workInProgress.type;var memoizedProps=workInProgress.memoizedProps;var nextProps=workInProgress.pendingProps;if(nextProps===null){nextProps=memoizedProps;!(nextProps!==null)?invariant(false,'We should always have pending or current props. This error is likely caused by a bug in React. Please file an issue.'):void 0;}var prevProps=current!==null?current.memoizedProps:null;if(hasContextChanged$1()){// Normally we can bail out on props equality but if context has changed
7402// we don't do the bailout and we have to reuse existing props instead.
7403}else if(nextProps===null||memoizedProps===nextProps){return bailoutOnAlreadyFinishedWork(current,workInProgress);}var nextChildren=nextProps.children;var isDirectTextChild=shouldSetTextContent(type,nextProps);if(isDirectTextChild){// We special case a direct text child of a host node. This is a common
7404// case. We won't handle it as a reified child. We will instead handle
7405// this in the host environment that also have access to this prop. That
7406// avoids allocating another HostText fiber and traversing it.
7407nextChildren=null;}else if(prevProps&&shouldSetTextContent(type,prevProps)){// If we're switching from a direct text child to a normal child, or to
7408// empty, we need to schedule the text content to be reset.

Callers 1

ReactFiberSchedulerFunction · 0.85

Calls 1

ReactFiberClassComponentFunction · 0.85

Tested by

no test coverage detected