MCPcopy
hub / github.com/facebook/react / performUnitOfWork

Function performUnitOfWork

packages/react-reconciler/src/ReactFiberWorkLoop.js:2990–3032  ·  view source on GitHub ↗
(unitOfWork: Fiber)

Source from the content-addressed store, hash-verified

2988}
2989
2990function performUnitOfWork(unitOfWork: Fiber): void {
2991 // The current, flushed, state of this fiber is the alternate. Ideally
2992 // nothing should rely on this, but relying on it here means that we don't
2993 // need an additional field on the work in progress.
2994 const current = unitOfWork.alternate;
2995
2996 let next;
2997 if (enableProfilerTimer && (unitOfWork.mode & ProfileMode) !== NoMode) {
2998 startProfilerTimer(unitOfWork);
2999 if (__DEV__) {
3000 next = runWithFiberInDEV(
3001 unitOfWork,
3002 beginWork,
3003 current,
3004 unitOfWork,
3005 entangledRenderLanes,
3006 );
3007 } else {
3008 next = beginWork(current, unitOfWork, entangledRenderLanes);
3009 }
3010 stopProfilerTimerIfRunningAndRecordDuration(unitOfWork);
3011 } else {
3012 if (__DEV__) {
3013 next = runWithFiberInDEV(
3014 unitOfWork,
3015 beginWork,
3016 current,
3017 unitOfWork,
3018 entangledRenderLanes,
3019 );
3020 } else {
3021 next = beginWork(current, unitOfWork, entangledRenderLanes);
3022 }
3023 }
3024
3025 unitOfWork.memoizedProps = unitOfWork.pendingProps;
3026 if (next === null) {
3027 // If this doesn't spawn new work, complete the current work.
3028 completeUnitOfWork(unitOfWork);
3029 } else {
3030 workInProgress = next;
3031 }
3032}
3033
3034function replaySuspendedUnitOfWork(unitOfWork: Fiber): void {
3035 // This is a fork of performUnitOfWork specifcally for replaying a fiber that

Callers 3

workLoopSyncFunction · 0.85
workLoopConcurrentFunction · 0.85

Calls 5

startProfilerTimerFunction · 0.90
runWithFiberInDEVFunction · 0.90
beginWorkFunction · 0.90
completeUnitOfWorkFunction · 0.85

Tested by

no test coverage detected