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

Function commitLifeCycles

lib/assets/react-source/development/react.js:23471–23645  ·  view source on GitHub ↗
(finishedRoot, current, finishedWork, committedExpirationTime)

Source from the content-addressed store, hash-verified

23469 }
23470
23471 function commitLifeCycles(finishedRoot, current, finishedWork, committedExpirationTime) {
23472 switch (finishedWork.tag) {
23473 case FunctionComponent:
23474 case ForwardRef:
23475 case SimpleMemoComponent:
23476 case Block:
23477 {
23478 // At this point layout effects have already been destroyed (during mutation phase).
23479 // This is done to prevent sibling component effects from interfering with each other,
23480 // e.g. a destroy function in one component should never override a ref set
23481 // by a create function in another component during the same commit.
23482 commitHookEffectListMount(Layout | HasEffect, finishedWork);
23483
23484 return;
23485 }
23486
23487 case ClassComponent:
23488 {
23489 var instance = finishedWork.stateNode;
23490
23491 if (finishedWork.effectTag & Update) {
23492 if (current === null) {
23493 startPhaseTimer(finishedWork, 'componentDidMount'); // We could update instance props and state here,
23494 // but instead we rely on them being set during last render.
23495 // TODO: revisit this when we implement resuming.
23496
23497 {
23498 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
23499 if (instance.props !== finishedWork.memoizedProps) {
23500 error('Expected %s props to match memoized props before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance');
23501 }
23502
23503 if (instance.state !== finishedWork.memoizedState) {
23504 error('Expected %s state to match memoized state before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance');
23505 }
23506 }
23507 }
23508
23509 instance.componentDidMount();
23510 stopPhaseTimer();
23511 } else {
23512 var prevProps = finishedWork.elementType === finishedWork.type ? current.memoizedProps : resolveDefaultProps(finishedWork.type, current.memoizedProps);
23513 var prevState = current.memoizedState;
23514 startPhaseTimer(finishedWork, 'componentDidUpdate'); // We could update instance props and state here,
23515 // but instead we rely on them being set during last render.
23516 // TODO: revisit this when we implement resuming.
23517
23518 {
23519 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
23520 if (instance.props !== finishedWork.memoizedProps) {
23521 error('Expected %s props to match memoized props before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance');
23522 }
23523
23524 if (instance.state !== finishedWork.memoizedState) {
23525 error('Expected %s state to match memoized state before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance');
23526 }
23527 }
23528 }

Callers 1

commitLayoutEffectsFunction · 0.85

Calls 11

startPhaseTimerFunction · 0.85
stopPhaseTimerFunction · 0.85
resolveDefaultPropsFunction · 0.85
commitUpdateQueueFunction · 0.85
getPublicInstanceFunction · 0.85
commitMountFunction · 0.85
getCommitTimeFunction · 0.85
errorFunction · 0.70
getComponentNameFunction · 0.70

Tested by

no test coverage detected