updateSimpleMemoComponent() — react Function Reference
Architecture documentation for the updateSimpleMemoComponent() function in ReactFiberBeginWork.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD d5867db8_c86c_35f1_776d_f9f063826e18["updateSimpleMemoComponent()"] 0be70812_cc0c_b210_f84f_8e61dd5f831c["ReactFiberBeginWork.js"] d5867db8_c86c_35f1_776d_f9f063826e18 -->|defined in| 0be70812_cc0c_b210_f84f_8e61dd5f831c a032b50f_d1ac_c367_9f15_394d8f0023c1["updateMemoComponent()"] a032b50f_d1ac_c367_9f15_394d8f0023c1 -->|calls| d5867db8_c86c_35f1_776d_f9f063826e18 235e1db1_02a4_912f_7d82_ea6636c850c0["beginWork()"] 235e1db1_02a4_912f_7d82_ea6636c850c0 -->|calls| d5867db8_c86c_35f1_776d_f9f063826e18 ec058345_39f3_16c0_234d_553132510c15["checkScheduledUpdateOrContext()"] d5867db8_c86c_35f1_776d_f9f063826e18 -->|calls| ec058345_39f3_16c0_234d_553132510c15 6cb202e6_76dc_0479_ff31_d0ef23610882["bailoutOnAlreadyFinishedWork()"] d5867db8_c86c_35f1_776d_f9f063826e18 -->|calls| 6cb202e6_76dc_0479_ff31_d0ef23610882 50e17875_d138_1098_df3a_5e5668c9be3d["updateFunctionComponent()"] d5867db8_c86c_35f1_776d_f9f063826e18 -->|calls| 50e17875_d138_1098_df3a_5e5668c9be3d style d5867db8_c86c_35f1_776d_f9f063826e18 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-reconciler/src/ReactFiberBeginWork.js lines 539–610
function updateSimpleMemoComponent(
current: Fiber | null,
workInProgress: Fiber,
Component: any,
nextProps: any,
renderLanes: Lanes,
): null | Fiber {
// TODO: current can be non-null here even if the component
// hasn't yet mounted. This happens when the inner render suspends.
// We'll need to figure out if this is fine or can cause issues.
if (current !== null) {
const prevProps = current.memoizedProps;
if (
shallowEqual(prevProps, nextProps) &&
current.ref === workInProgress.ref &&
// Prevent bailout if the implementation changed due to hot reload.
(__DEV__ ? workInProgress.type === current.type : true)
) {
didReceiveUpdate = false;
// The props are shallowly equal. Reuse the previous props object, like we
// would during a normal fiber bailout.
//
// We don't have strong guarantees that the props object is referentially
// equal during updates where we can't bail out anyway — like if the props
// are shallowly equal, but there's a local state or context update in the
// same batch.
//
// However, as a principle, we should aim to make the behavior consistent
// across different ways of memoizing a component. For example, React.memo
// has a different internal Fiber layout if you pass a normal function
// component (SimpleMemoComponent) versus if you pass a different type
// like forwardRef (MemoComponent). But this is an implementation detail.
// Wrapping a component in forwardRef (or React.lazy, etc) shouldn't
// affect whether the props object is reused during a bailout.
workInProgress.pendingProps = nextProps = prevProps;
if (!checkScheduledUpdateOrContext(current, renderLanes)) {
// The pending lanes were cleared at the beginning of beginWork. We're
// about to bail out, but there might be other lanes that weren't
// included in the current render. Usually, the priority level of the
// remaining updates is accumulated during the evaluation of the
// component (i.e. when processing the update queue). But since since
// we're bailing out early *without* evaluating the component, we need
// to account for it here, too. Reset to the value of the current fiber.
// NOTE: This only applies to SimpleMemoComponent, not MemoComponent,
// because a MemoComponent fiber does not have hooks or an update queue;
// rather, it wraps around an inner component, which may or may not
// contains hooks.
// TODO: Move the reset at in beginWork out of the common path so that
// this is no longer necessary.
workInProgress.lanes = current.lanes;
return bailoutOnAlreadyFinishedWork(
current,
workInProgress,
renderLanes,
);
} else if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) {
// This is a special case that only exists for legacy mode.
// See https://github.com/facebook/react/pull/19216.
didReceiveUpdate = true;
}
}
}
return updateFunctionComponent(
current,
workInProgress,
Component,
nextProps,
renderLanes,
);
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does updateSimpleMemoComponent() do?
updateSimpleMemoComponent() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberBeginWork.js.
Where is updateSimpleMemoComponent() defined?
updateSimpleMemoComponent() is defined in packages/react-reconciler/src/ReactFiberBeginWork.js at line 539.
What does updateSimpleMemoComponent() call?
updateSimpleMemoComponent() calls 3 function(s): bailoutOnAlreadyFinishedWork, checkScheduledUpdateOrContext, updateFunctionComponent.
What calls updateSimpleMemoComponent()?
updateSimpleMemoComponent() is called by 2 function(s): beginWork, updateMemoComponent.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free