MCPcopy Index your code
hub / github.com/microsoft/SandDance / updateSimpleMemoComponent

Function updateSimpleMemoComponent

docs/external/js/react-dom.development.js:17053–17108  ·  view source on GitHub ↗
(current, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime)

Source from the content-addressed store, hash-verified

17051 }
17052
17053 function updateSimpleMemoComponent(current, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
17054 // TODO: current can be non-null here even if the component
17055 // hasn't yet mounted. This happens when the inner render suspends.
17056 // We'll need to figure out if this is fine or can cause issues.
17057 {
17058 if (workInProgress.type !== workInProgress.elementType) {
17059 // Lazy component props can't be validated in createElement
17060 // because they're only guaranteed to be resolved here.
17061 var outerMemoType = workInProgress.elementType;
17062
17063 if (outerMemoType.$$typeof === REACT_LAZY_TYPE) {
17064 // We warn when you define propTypes on lazy()
17065 // so let's just skip over it to find memo() outer wrapper.
17066 // Inner props for memo are validated later.
17067 outerMemoType = refineResolvedLazyComponent(outerMemoType);
17068 }
17069
17070 var outerPropTypes = outerMemoType && outerMemoType.propTypes;
17071
17072 if (outerPropTypes) {
17073 checkPropTypes_1(outerPropTypes, nextProps, // Resolved (SimpleMemoComponent has no defaultProps)
17074 'prop', getComponentName(outerMemoType), getCurrentFiberStackInDev);
17075 } // Inner propTypes will be validated in the function component path.
17076
17077 }
17078 }
17079
17080 if (current !== null) {
17081 var prevProps = current.memoizedProps;
17082
17083 if (shallowEqual(prevProps, nextProps) && current.ref === workInProgress.ref && ( // Prevent bailout if the implementation changed due to hot reload.
17084 workInProgress.type === current.type )) {
17085 didReceiveUpdate = false;
17086
17087 if (updateExpirationTime < renderExpirationTime) {
17088 // The pending update priority was cleared at the beginning of
17089 // beginWork. We're about to bail out, but there might be additional
17090 // updates at a lower priority. Usually, the priority level of the
17091 // remaining updates is accumlated during the evaluation of the
17092 // component (i.e. when processing the update queue). But since since
17093 // we're bailing out early *without* evaluating the component, we need
17094 // to account for it here, too. Reset to the value of the current fiber.
17095 // NOTE: This only applies to SimpleMemoComponent, not MemoComponent,
17096 // because a MemoComponent fiber does not have hooks or an update queue;
17097 // rather, it wraps around an inner component, which may or may not
17098 // contains hooks.
17099 // TODO: Move the reset at in beginWork out of the common path so that
17100 // this is no longer necessary.
17101 workInProgress.expirationTime = current.expirationTime;
17102 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
17103 }
17104 }
17105 }
17106
17107 return updateFunctionComponent(current, workInProgress, Component, nextProps, renderExpirationTime);
17108 }
17109
17110 function updateFragment(current, workInProgress, renderExpirationTime) {

Callers 2

updateMemoComponentFunction · 0.85
beginWorkFunction · 0.85

Calls 5

shallowEqualFunction · 0.85
updateFunctionComponentFunction · 0.85
getComponentNameFunction · 0.70

Tested by

no test coverage detected