completeWork() — react Function Reference
Architecture documentation for the completeWork() function in ReactFiberCompleteWork.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 0b8db832_87fd_e560_8aa8_e2b319c81626["completeWork()"] 6b05669d_2f09_63a5_e79f_0afc195f25a3["ReactFiberCompleteWork.js"] 0b8db832_87fd_e560_8aa8_e2b319c81626 -->|defined in| 6b05669d_2f09_63a5_e79f_0afc195f25a3 1a7e7cc1_6419_de9c_0611_6890ef404e66["bubbleProperties()"] 0b8db832_87fd_e560_8aa8_e2b319c81626 -->|calls| 1a7e7cc1_6419_de9c_0611_6890ef404e66 696b3a85_2c29_d1fc_9da0_cb0ebaa5bcff["popCacheProvider()"] 0b8db832_87fd_e560_8aa8_e2b319c81626 -->|calls| 696b3a85_2c29_d1fc_9da0_cb0ebaa5bcff 2343b46f_12ff_c0a8_2d57_670c055844f4["popRootMarkerInstance()"] 0b8db832_87fd_e560_8aa8_e2b319c81626 -->|calls| 2343b46f_12ff_c0a8_2d57_670c055844f4 3a69c559_be56_4689_1458_b935319852cb["popHostContainer()"] 0b8db832_87fd_e560_8aa8_e2b319c81626 -->|calls| 3a69c559_be56_4689_1458_b935319852cb b741356a_b031_e7cd_ea5d_ed59f056748d["popHydrationState()"] 0b8db832_87fd_e560_8aa8_e2b319c81626 -->|calls| b741356a_b031_e7cd_ea5d_ed59f056748d 62389190_5e71_b961_f5c1_ce663e236915["markUpdate()"] 0b8db832_87fd_e560_8aa8_e2b319c81626 -->|calls| 62389190_5e71_b961_f5c1_ce663e236915 3cccd78e_6f36_bda1_da89_ea302f4aca1a["updateHostContainer()"] 0b8db832_87fd_e560_8aa8_e2b319c81626 -->|calls| 3cccd78e_6f36_bda1_da89_ea302f4aca1a f416042c_1372_a9d9_9727_83f52f21014b["preloadResourceAndSuspendIfNeeded()"] 0b8db832_87fd_e560_8aa8_e2b319c81626 -->|calls| f416042c_1372_a9d9_9727_83f52f21014b 172f6fb3_884c_b82e_7101_379f58af5f8a["preloadInstanceAndSuspendIfNeeded()"] 0b8db832_87fd_e560_8aa8_e2b319c81626 -->|calls| 172f6fb3_884c_b82e_7101_379f58af5f8a 17f65ca7_1e68_0419_b46a_9bf4b1b54b06["updateHostComponent()"] 0b8db832_87fd_e560_8aa8_e2b319c81626 -->|calls| 17f65ca7_1e68_0419_b46a_9bf4b1b54b06 d1a95e98_467c_e9b8_af34_7d3813a82b6b["popHostContext()"] 0b8db832_87fd_e560_8aa8_e2b319c81626 -->|calls| d1a95e98_467c_e9b8_af34_7d3813a82b6b caaf30b2_6e58_ce4e_f73c_baa2c3b083d0["getRootHostContainer()"] 0b8db832_87fd_e560_8aa8_e2b319c81626 -->|calls| caaf30b2_6e58_ce4e_f73c_baa2c3b083d0 950cf4f4_84e4_d7d6_01b0_f2c00f238dae["getHostContext()"] 0b8db832_87fd_e560_8aa8_e2b319c81626 -->|calls| 950cf4f4_84e4_d7d6_01b0_f2c00f238dae style 0b8db832_87fd_e560_8aa8_e2b319c81626 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-reconciler/src/ReactFiberCompleteWork.js lines 1068–2079
function completeWork(
current: Fiber | null,
workInProgress: Fiber,
renderLanes: Lanes,
): Fiber | null {
const newProps = workInProgress.pendingProps;
// Note: This intentionally doesn't check if we're hydrating because comparing
// to the current tree provider fiber is just as fast and less error-prone.
// Ideally we would have a special version of the work loop only
// for hydration.
popTreeContext(workInProgress);
switch (workInProgress.tag) {
case IncompleteFunctionComponent: {
if (disableLegacyMode) {
break;
}
// Fallthrough
}
case LazyComponent:
case SimpleMemoComponent:
case FunctionComponent:
case ForwardRef:
case Fragment:
case Mode:
case Profiler:
case ContextConsumer:
case MemoComponent:
bubbleProperties(workInProgress);
return null;
case ClassComponent: {
const Component = workInProgress.type;
if (isLegacyContextProvider(Component)) {
popLegacyContext(workInProgress);
}
bubbleProperties(workInProgress);
return null;
}
case HostRoot: {
const fiberRoot = (workInProgress.stateNode: FiberRoot);
if (enableTransitionTracing) {
const transitions = getWorkInProgressTransitions();
// We set the Passive flag here because if there are new transitions,
// we will need to schedule callbacks and process the transitions,
// which we do in the passive phase
if (transitions !== null) {
workInProgress.flags |= Passive;
}
}
let previousCache: Cache | null = null;
if (current !== null) {
previousCache = current.memoizedState.cache;
}
const cache: Cache = workInProgress.memoizedState.cache;
if (cache !== previousCache) {
// Run passive effects to retain/release the cache.
workInProgress.flags |= Passive;
}
popCacheProvider(workInProgress, cache);
if (enableTransitionTracing) {
popRootMarkerInstance(workInProgress);
}
popRootTransition(workInProgress, fiberRoot, renderLanes);
popHostContainer(workInProgress);
popTopLevelLegacyContextObject(workInProgress);
if (fiberRoot.pendingContext) {
fiberRoot.context = fiberRoot.pendingContext;
fiberRoot.pendingContext = null;
}
if (current === null || current.child === null) {
// If we hydrated, pop so that we can delete any remaining children
// that weren't hydrated.
const wasHydrated = popHydrationState(workInProgress);
if (wasHydrated) {
emitPendingHydrationWarnings();
// If we hydrated, then we'll need to schedule an update for
// the commit side-effects on the root.
markUpdate(workInProgress);
Domain
Subdomains
Calls
- appendAllChildren()
- bubbleProperties()
- completeDehydratedActivityBoundary()
- completeDehydratedSuspenseBoundary()
- cutOffTailIfNeeded()
- getHostContext()
- getIsHydrating()
- getRootHostContainer()
- isOnlyNewMounts()
- markCloned()
- markUpdate()
- popCacheProvider()
- popHiddenContext()
- popHostContainer()
- popHostContext()
- popHydrationState()
- popMarkerInstance()
- popRootMarkerInstance()
- popSuspenseHandler()
- popSuspenseListContext()
- preloadInstanceAndSuspendIfNeeded()
- preloadResourceAndSuspendIfNeeded()
- prepareToHydrateHostInstance()
- prepareToHydrateHostTextInstance()
- pushSuspenseListCatch()
- pushSuspenseListContext()
- resetChildFibers()
- scheduleRetryEffect()
- setDefaultShallowSuspenseListContext()
- setShallowSuspenseListContext()
- updateHostComponent()
- updateHostContainer()
- updateHostText()
Source
Frequently Asked Questions
What does completeWork() do?
completeWork() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberCompleteWork.js.
Where is completeWork() defined?
completeWork() is defined in packages/react-reconciler/src/ReactFiberCompleteWork.js at line 1068.
What does completeWork() call?
completeWork() calls 33 function(s): appendAllChildren, bubbleProperties, completeDehydratedActivityBoundary, completeDehydratedSuspenseBoundary, cutOffTailIfNeeded, getHostContext, getIsHydrating, getRootHostContainer, and 25 more.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free