MCPcopy Create free account
hub / github.com/plotly/dash / updateSimpleMemoComponent

Function updateSimpleMemoComponent

dash/deps/react-dom@18.3.1.js:19382–19465  ·  view source on GitHub ↗
(current, workInProgress, Component, nextProps, renderLanes)

Source from the content-addressed store, hash-verified

19380 }
19381
19382 function updateSimpleMemoComponent(current, workInProgress, Component, nextProps, renderLanes) {
19383 // TODO: current can be non-null here even if the component
19384 // hasn't yet mounted. This happens when the inner render suspends.
19385 // We'll need to figure out if this is fine or can cause issues.
19386 {
19387 if (workInProgress.type !== workInProgress.elementType) {
19388 // Lazy component props can't be validated in createElement
19389 // because they're only guaranteed to be resolved here.
19390 var outerMemoType = workInProgress.elementType;
19391
19392 if (outerMemoType.$$typeof === REACT_LAZY_TYPE) {
19393 // We warn when you define propTypes on lazy()
19394 // so let's just skip over it to find memo() outer wrapper.
19395 // Inner props for memo are validated later.
19396 var lazyComponent = outerMemoType;
19397 var payload = lazyComponent._payload;
19398 var init = lazyComponent._init;
19399
19400 try {
19401 outerMemoType = init(payload);
19402 } catch (x) {
19403 outerMemoType = null;
19404 } // Inner propTypes will be validated in the function component path.
19405
19406
19407 var outerPropTypes = outerMemoType && outerMemoType.propTypes;
19408
19409 if (outerPropTypes) {
19410 checkPropTypes(outerPropTypes, nextProps, // Resolved (SimpleMemoComponent has no defaultProps)
19411 'prop', getComponentNameFromType(outerMemoType));
19412 }
19413 }
19414 }
19415 }
19416
19417 if (current !== null) {
19418 var prevProps = current.memoizedProps;
19419
19420 if (shallowEqual(prevProps, nextProps) && current.ref === workInProgress.ref && ( // Prevent bailout if the implementation changed due to hot reload.
19421 workInProgress.type === current.type )) {
19422 didReceiveUpdate = false; // The props are shallowly equal. Reuse the previous props object, like we
19423 // would during a normal fiber bailout.
19424 //
19425 // We don't have strong guarantees that the props object is referentially
19426 // equal during updates where we can't bail out anyway — like if the props
19427 // are shallowly equal, but there's a local state or context update in the
19428 // same batch.
19429 //
19430 // However, as a principle, we should aim to make the behavior consistent
19431 // across different ways of memoizing a component. For example, React.memo
19432 // has a different internal Fiber layout if you pass a normal function
19433 // component (SimpleMemoComponent) versus if you pass a different type
19434 // like forwardRef (MemoComponent). But this is an implementation detail.
19435 // Wrapping a component in forwardRef (or React.lazy, etc) shouldn't
19436 // affect whether the props object is reused during a bailout.
19437
19438 workInProgress.pendingProps = nextProps = prevProps;
19439

Callers 2

updateMemoComponentFunction · 0.70
beginWorkFunction · 0.70

Calls 6

checkPropTypesFunction · 0.70
getComponentNameFromTypeFunction · 0.70
shallowEqualFunction · 0.70
updateFunctionComponentFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…