commitLayoutEffectOnFiber() — react Function Reference
Architecture documentation for the commitLayoutEffectOnFiber() function in ReactFiberCommitWork.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD ce61aa22_42d2_811a_b317_96c8d0cb0321["commitLayoutEffectOnFiber()"] e0fbfbd5_47b0_a489_0b36_bbfad9245544["ReactFiberCommitWork.js"] ce61aa22_42d2_811a_b317_96c8d0cb0321 -->|defined in| e0fbfbd5_47b0_a489_0b36_bbfad9245544 09adf792_b813_7366_9451_35d0c93c55bb["commitLayoutEffects()"] 09adf792_b813_7366_9451_35d0c93c55bb -->|calls| ce61aa22_42d2_811a_b317_96c8d0cb0321 2250e6b2_2154_c133_8784_3a5be3de5ea6["recursivelyTraverseLayoutEffects()"] 2250e6b2_2154_c133_8784_3a5be3de5ea6 -->|calls| ce61aa22_42d2_811a_b317_96c8d0cb0321 4f76ed87_f151_2295_8bb4_c7b5dfe010a2["pushComponentEffectStart()"] ce61aa22_42d2_811a_b317_96c8d0cb0321 -->|calls| 4f76ed87_f151_2295_8bb4_c7b5dfe010a2 da570743_1675_9fe9_6425_06d6a84f49ba["pushComponentEffectDuration()"] ce61aa22_42d2_811a_b317_96c8d0cb0321 -->|calls| da570743_1675_9fe9_6425_06d6a84f49ba 2250e6b2_2154_c133_8784_3a5be3de5ea6["recursivelyTraverseLayoutEffects()"] ce61aa22_42d2_811a_b317_96c8d0cb0321 -->|calls| 2250e6b2_2154_c133_8784_3a5be3de5ea6 a9dc2423_dea6_d2a0_0ec6_d7730bfd6c66["commitHookLayoutEffects()"] ce61aa22_42d2_811a_b317_96c8d0cb0321 -->|calls| a9dc2423_dea6_d2a0_0ec6_d7730bfd6c66 e2aa7e1c_c4bf_b49f_2759_ec6a5e7b2f89["commitClassLayoutLifecycles()"] ce61aa22_42d2_811a_b317_96c8d0cb0321 -->|calls| e2aa7e1c_c4bf_b49f_2759_ec6a5e7b2f89 1742f4ab_88cb_1f5c_9378_61760e273398["commitClassCallbacks()"] ce61aa22_42d2_811a_b317_96c8d0cb0321 -->|calls| 1742f4ab_88cb_1f5c_9378_61760e273398 0173a090_1c78_3da9_68fd_5bfa21600acc["pushNestedEffectDurations()"] ce61aa22_42d2_811a_b317_96c8d0cb0321 -->|calls| 0173a090_1c78_3da9_68fd_5bfa21600acc 006c62ff_dc21_a892_060f_b8af1c4c9d34["popNestedEffectDurations()"] ce61aa22_42d2_811a_b317_96c8d0cb0321 -->|calls| 006c62ff_dc21_a892_060f_b8af1c4c9d34 23ba532d_d2ea_c5f1_a931_97dc52085704["commitHostMount()"] ce61aa22_42d2_811a_b317_96c8d0cb0321 -->|calls| 23ba532d_d2ea_c5f1_a931_97dc52085704 5eff5a20_f686_8ccf_46af_3522917606e4["commitHostHydratedInstance()"] ce61aa22_42d2_811a_b317_96c8d0cb0321 -->|calls| 5eff5a20_f686_8ccf_46af_3522917606e4 2bc3a25f_8722_3ff5_8d20_3b3d595f7eda["bubbleNestedEffectDurations()"] ce61aa22_42d2_811a_b317_96c8d0cb0321 -->|calls| 2bc3a25f_8722_3ff5_8d20_3b3d595f7eda 9b0f5b9a_5907_c1d2_699c_448228d8f869["commitActivityHydrationCallbacks()"] ce61aa22_42d2_811a_b317_96c8d0cb0321 -->|calls| 9b0f5b9a_5907_c1d2_699c_448228d8f869 style ce61aa22_42d2_811a_b317_96c8d0cb0321 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-reconciler/src/ReactFiberCommitWork.js lines 591–916
function commitLayoutEffectOnFiber(
finishedRoot: FiberRoot,
current: Fiber | null,
finishedWork: Fiber,
committedLanes: Lanes,
): void {
const prevEffectStart = pushComponentEffectStart();
const prevEffectDuration = pushComponentEffectDuration();
const prevEffectErrors = pushComponentEffectErrors();
const prevEffectDidSpawnUpdate = pushComponentEffectDidSpawnUpdate();
// When updating this function, also update reappearLayoutEffects, which does
// most of the same things when an offscreen tree goes from hidden -> visible.
const flags = finishedWork.flags;
switch (finishedWork.tag) {
case FunctionComponent:
case ForwardRef:
case SimpleMemoComponent: {
recursivelyTraverseLayoutEffects(
finishedRoot,
finishedWork,
committedLanes,
);
if (flags & Update) {
commitHookLayoutEffects(finishedWork, HookLayout | HookHasEffect);
}
break;
}
case ClassComponent: {
recursivelyTraverseLayoutEffects(
finishedRoot,
finishedWork,
committedLanes,
);
if (flags & Update) {
commitClassLayoutLifecycles(finishedWork, current);
}
if (flags & Callback) {
commitClassCallbacks(finishedWork);
}
if (flags & Ref) {
safelyAttachRef(finishedWork, finishedWork.return);
}
break;
}
case HostRoot: {
const prevProfilerEffectDuration = pushNestedEffectDurations();
recursivelyTraverseLayoutEffects(
finishedRoot,
finishedWork,
committedLanes,
);
if (flags & Callback) {
commitRootCallbacks(finishedWork);
}
if (enableProfilerTimer && enableProfilerCommitHooks) {
finishedRoot.effectDuration += popNestedEffectDurations(
prevProfilerEffectDuration,
);
}
break;
}
case HostSingleton: {
if (supportsSingletons) {
// We acquire the singleton instance first so it has appropriate
// styles before other layout effects run. This isn't perfect because
// an early sibling of the singleton may have an effect that can
// observe the singleton before it is acquired.
// @TODO move this to the mutation phase. The reason it isn't there yet
// is it seemingly requires an extra traversal because we need to move the
// disappear effect into a phase before the appear phase
if (current === null && flags & Update) {
// Unlike in the reappear path we only acquire on new mount
commitHostSingletonAcquisition(finishedWork);
}
// We fall through to the HostComponent case below.
}
// Fallthrough
}
case HostHoistable:
Domain
Subdomains
Calls
- bubbleNestedEffectDurations()
- commitActivityHydrationCallbacks()
- commitClassCallbacks()
- commitClassLayoutLifecycles()
- commitHookLayoutEffects()
- commitHostHydratedInstance()
- commitHostMount()
- commitSuspenseHydrationCallbacks()
- isHydratingParent()
- popComponentEffectDuration()
- popComponentEffectStart()
- popNestedEffectDurations()
- pushComponentEffectDuration()
- pushComponentEffectStart()
- pushNestedEffectDurations()
- recursivelyTraverseLayoutEffects()
- recursivelyTraverseReappearLayoutEffects()
- trackNamedViewTransition()
Source
Frequently Asked Questions
What does commitLayoutEffectOnFiber() do?
commitLayoutEffectOnFiber() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberCommitWork.js.
Where is commitLayoutEffectOnFiber() defined?
commitLayoutEffectOnFiber() is defined in packages/react-reconciler/src/ReactFiberCommitWork.js at line 591.
What does commitLayoutEffectOnFiber() call?
commitLayoutEffectOnFiber() calls 18 function(s): bubbleNestedEffectDurations, commitActivityHydrationCallbacks, commitClassCallbacks, commitClassLayoutLifecycles, commitHookLayoutEffects, commitHostHydratedInstance, commitHostMount, commitSuspenseHydrationCallbacks, and 10 more.
What calls commitLayoutEffectOnFiber()?
commitLayoutEffectOnFiber() is called by 2 function(s): commitLayoutEffects, recursivelyTraverseLayoutEffects.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free