MCPcopy Create free account
hub / github.com/reactjs/react-rails / beginWork

Function beginWork

lib/assets/react-source/development/react.js:22105–22406  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

22103 }
22104
22105 function beginWork(current, workInProgress, renderExpirationTime) {
22106 var updateExpirationTime = workInProgress.expirationTime;
22107
22108 {
22109 if (workInProgress._debugNeedsRemount && current !== null) {
22110 // This will restart the begin phase with a new fiber.
22111 return remountFiber(current, workInProgress, createFiberFromTypeAndProps(workInProgress.type, workInProgress.key, workInProgress.pendingProps, workInProgress._debugOwner || null, workInProgress.mode, workInProgress.expirationTime));
22112 }
22113 }
22114
22115 if (current !== null) {
22116 var oldProps = current.memoizedProps;
22117 var newProps = workInProgress.pendingProps;
22118
22119 if (oldProps !== newProps || hasContextChanged() || ( // Force a re-render if the implementation changed due to hot reload:
22120 workInProgress.type !== current.type )) {
22121 // If props or context changed, mark the fiber as having performed work.
22122 // This may be unset if the props are determined to be equal later (memo).
22123 didReceiveUpdate = true;
22124 } else if (updateExpirationTime < renderExpirationTime) {
22125 didReceiveUpdate = false; // This fiber does not have any pending work. Bailout without entering
22126 // the begin phase. There's still some bookkeeping we that needs to be done
22127 // in this optimized path, mostly pushing stuff onto the stack.
22128
22129 switch (workInProgress.tag) {
22130 case HostRoot:
22131 pushHostRootContext(workInProgress);
22132 resetHydrationState();
22133 break;
22134
22135 case HostComponent:
22136 pushHostContext(workInProgress);
22137
22138 if (workInProgress.mode & ConcurrentMode && renderExpirationTime !== Never && shouldDeprioritizeSubtree(workInProgress.type, newProps)) {
22139 {
22140 markSpawnedWork(Never);
22141 } // Schedule this fiber to re-render at offscreen priority. Then bailout.
22142
22143
22144 workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
22145 return null;
22146 }
22147
22148 break;
22149
22150 case ClassComponent:
22151 {
22152 var Component = workInProgress.type;
22153
22154 if (isContextProvider(Component)) {
22155 pushContextProvider(workInProgress);
22156 }
22157
22158 break;
22159 }
22160
22161 case HostPortal:
22162 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);

Callers 1

react.jsFile · 0.85

Calls 15

remountFiberFunction · 0.85
hasContextChangedFunction · 0.85
pushHostRootContextFunction · 0.85
resetHydrationStateFunction · 0.85
pushHostContextFunction · 0.85
markSpawnedWorkFunction · 0.85
pushContextProviderFunction · 0.85
pushHostContainerFunction · 0.85
pushProviderFunction · 0.85
updateSuspenseComponentFunction · 0.85

Tested by

no test coverage detected