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

Function updateClassComponent

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

Source from the content-addressed store, hash-verified

20750 }
20751
20752 function updateClassComponent(current, workInProgress, Component, nextProps, renderExpirationTime) {
20753 {
20754 if (workInProgress.type !== workInProgress.elementType) {
20755 // Lazy component props can't be validated in createElement
20756 // because they're only guaranteed to be resolved here.
20757 var innerPropTypes = Component.propTypes;
20758
20759 if (innerPropTypes) {
20760 checkPropTypes(innerPropTypes, nextProps, // Resolved props
20761 'prop', getComponentName(Component), getCurrentFiberStackInDev);
20762 }
20763 }
20764 } // Push context providers early to prevent context stack mismatches.
20765 // During mounting we don't know the child context yet as the instance doesn't exist.
20766 // We will invalidate the child context in finishClassComponent() right after rendering.
20767
20768
20769 var hasContext;
20770
20771 if (isContextProvider(Component)) {
20772 hasContext = true;
20773 pushContextProvider(workInProgress);
20774 } else {
20775 hasContext = false;
20776 }
20777
20778 prepareToReadContext(workInProgress, renderExpirationTime);
20779 var instance = workInProgress.stateNode;
20780 var shouldUpdate;
20781
20782 if (instance === null) {
20783 if (current !== null) {
20784 // A class component without an instance only mounts if it suspended
20785 // inside a non-concurrent tree, in an inconsistent state. We want to
20786 // treat it like a new mount, even though an empty version of it already
20787 // committed. Disconnect the alternate pointers.
20788 current.alternate = null;
20789 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
20790
20791 workInProgress.effectTag |= Placement;
20792 } // In the initial pass we might need to construct the instance.
20793
20794
20795 constructClassInstance(workInProgress, Component, nextProps);
20796 mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
20797 shouldUpdate = true;
20798 } else if (current === null) {
20799 // In a resume, we'll already have an instance we can reuse.
20800 shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
20801 } else {
20802 shouldUpdate = updateClassInstance(current, workInProgress, Component, nextProps, renderExpirationTime);
20803 }
20804
20805 var nextUnitOfWork = finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime);
20806
20807 {
20808 var inst = workInProgress.stateNode;
20809

Callers 2

mountLazyComponentFunction · 0.85
beginWorkFunction · 0.85

Calls 11

pushContextProviderFunction · 0.85
prepareToReadContextFunction · 0.85
constructClassInstanceFunction · 0.85
mountClassInstanceFunction · 0.85
resumeMountClassInstanceFunction · 0.85
updateClassInstanceFunction · 0.85
finishClassComponentFunction · 0.85
checkPropTypesFunction · 0.70
getComponentNameFunction · 0.70
isContextProviderFunction · 0.70
errorFunction · 0.70

Tested by

no test coverage detected