MCPcopy Create free account
hub / github.com/reactjs/react-rails / updateMemoComponent

Function updateMemoComponent

lib/assets/react-source/development/react.js:20534–20611  ·  view source on GitHub ↗
(current, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime)

Source from the content-addressed store, hash-verified

20532 }
20533
20534 function updateMemoComponent(current, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
20535 if (current === null) {
20536 var type = Component.type;
20537
20538 if (isSimpleFunctionComponent(type) && Component.compare === null && // SimpleMemoComponent codepath doesn't resolve outer props either.
20539 Component.defaultProps === undefined) {
20540 var resolvedType = type;
20541
20542 {
20543 resolvedType = resolveFunctionForHotReloading(type);
20544 } // If this is a plain function component without default props,
20545 // and with only the default shallow comparison, we upgrade it
20546 // to a SimpleMemoComponent to allow fast path updates.
20547
20548
20549 workInProgress.tag = SimpleMemoComponent;
20550 workInProgress.type = resolvedType;
20551
20552 {
20553 validateFunctionComponentInDev(workInProgress, type);
20554 }
20555
20556 return updateSimpleMemoComponent(current, workInProgress, resolvedType, nextProps, updateExpirationTime, renderExpirationTime);
20557 }
20558
20559 {
20560 var innerPropTypes = type.propTypes;
20561
20562 if (innerPropTypes) {
20563 // Inner memo component props aren't currently validated in createElement.
20564 // We could move it there, but we'd still need this for lazy code path.
20565 checkPropTypes(innerPropTypes, nextProps, // Resolved props
20566 'prop', getComponentName(type), getCurrentFiberStackInDev);
20567 }
20568 }
20569
20570 var child = createFiberFromTypeAndProps(Component.type, null, nextProps, null, workInProgress.mode, renderExpirationTime);
20571 child.ref = workInProgress.ref;
20572 child.return = workInProgress;
20573 workInProgress.child = child;
20574 return child;
20575 }
20576
20577 {
20578 var _type = Component.type;
20579 var _innerPropTypes = _type.propTypes;
20580
20581 if (_innerPropTypes) {
20582 // Inner memo component props aren't currently validated in createElement.
20583 // We could move it there, but we'd still need this for lazy code path.
20584 checkPropTypes(_innerPropTypes, nextProps, // Resolved props
20585 'prop', getComponentName(_type), getCurrentFiberStackInDev);
20586 }
20587 }
20588
20589 var currentChild = current.child; // This is always exactly one child
20590
20591 if (updateExpirationTime < renderExpirationTime) {

Callers 2

mountLazyComponentFunction · 0.85
beginWorkFunction · 0.85

Calls 10

compareFunction · 0.85
createWorkInProgressFunction · 0.85
checkPropTypesFunction · 0.70
getComponentNameFunction · 0.70

Tested by

no test coverage detected