(current, workInProgress, Component, nextProps, renderLanes)
| 19351 | } |
| 19352 | |
| 19353 | function updateSimpleMemoComponent(current, workInProgress, Component, nextProps, renderLanes) { |
| 19354 | // TODO: current can be non-null here even if the component |
| 19355 | // hasn't yet mounted. This happens when the inner render suspends. |
| 19356 | // We'll need to figure out if this is fine or can cause issues. |
| 19357 | { |
| 19358 | if (workInProgress.type !== workInProgress.elementType) { |
| 19359 | // Lazy component props can't be validated in createElement |
| 19360 | // because they're only guaranteed to be resolved here. |
| 19361 | var outerMemoType = workInProgress.elementType; |
| 19362 | |
| 19363 | if (outerMemoType.$$typeof === REACT_LAZY_TYPE) { |
| 19364 | // We warn when you define propTypes on lazy() |
| 19365 | // so let's just skip over it to find memo() outer wrapper. |
| 19366 | // Inner props for memo are validated later. |
| 19367 | var lazyComponent = outerMemoType; |
| 19368 | var payload = lazyComponent._payload; |
| 19369 | var init = lazyComponent._init; |
| 19370 | |
| 19371 | try { |
| 19372 | outerMemoType = init(payload); |
| 19373 | } catch (x) { |
| 19374 | outerMemoType = null; |
| 19375 | } // Inner propTypes will be validated in the function component path. |
| 19376 | |
| 19377 | |
| 19378 | var outerPropTypes = outerMemoType && outerMemoType.propTypes; |
| 19379 | |
| 19380 | if (outerPropTypes) { |
| 19381 | checkPropTypes(outerPropTypes, nextProps, // Resolved (SimpleMemoComponent has no defaultProps) |
| 19382 | 'prop', getComponentNameFromType(outerMemoType)); |
| 19383 | } |
| 19384 | } |
| 19385 | } |
| 19386 | } |
| 19387 | |
| 19388 | if (current !== null) { |
| 19389 | var prevProps = current.memoizedProps; |
| 19390 | |
| 19391 | if (shallowEqual(prevProps, nextProps) && current.ref === workInProgress.ref && ( // Prevent bailout if the implementation changed due to hot reload. |
| 19392 | workInProgress.type === current.type )) { |
| 19393 | didReceiveUpdate = false; // The props are shallowly equal. Reuse the previous props object, like we |
| 19394 | // would during a normal fiber bailout. |
| 19395 | // |
| 19396 | // We don't have strong guarantees that the props object is referentially |
| 19397 | // equal during updates where we can't bail out anyway — like if the props |
| 19398 | // are shallowly equal, but there's a local state or context update in the |
| 19399 | // same batch. |
| 19400 | // |
| 19401 | // However, as a principle, we should aim to make the behavior consistent |
| 19402 | // across different ways of memoizing a component. For example, React.memo |
| 19403 | // has a different internal Fiber layout if you pass a normal function |
| 19404 | // component (SimpleMemoComponent) versus if you pass a different type |
| 19405 | // like forwardRef (MemoComponent). But this is an implementation detail. |
| 19406 | // Wrapping a component in forwardRef (or React.lazy, etc) shouldn't |
| 19407 | // affect whether the props object is reused during a bailout. |
| 19408 | |
| 19409 | workInProgress.pendingProps = nextProps = prevProps; |
| 19410 |
no test coverage detected
searching dependent graphs…