MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / commitLifeCycles

Function commitLifeCycles

code/one-direction-data-flow/public/app.js:11131–11209  ·  view source on GitHub ↗
(finishedRoot, current, finishedWork, currentTime, committedExpirationTime)

Source from the content-addressed store, hash-verified

11129 }
11130
11131 function commitLifeCycles(finishedRoot, current, finishedWork, currentTime, committedExpirationTime) {
11132 switch (finishedWork.tag) {
11133 case ClassComponent:
11134 {
11135 var _instance = finishedWork.stateNode;
11136 if (finishedWork.effectTag & Update) {
11137 if (current === null) {
11138 startPhaseTimer(finishedWork, 'componentDidMount');
11139 _instance.props = finishedWork.memoizedProps;
11140 _instance.state = finishedWork.memoizedState;
11141 _instance.componentDidMount();
11142 stopPhaseTimer();
11143 } else {
11144 var prevProps = current.memoizedProps;
11145 var prevState = current.memoizedState;
11146 startPhaseTimer(finishedWork, 'componentDidUpdate');
11147 _instance.props = finishedWork.memoizedProps;
11148 _instance.state = finishedWork.memoizedState;
11149 _instance.componentDidUpdate(prevProps, prevState);
11150 stopPhaseTimer();
11151 }
11152 }
11153 var updateQueue = finishedWork.updateQueue;
11154 if (updateQueue !== null) {
11155 commitCallbacks(updateQueue, _instance);
11156 }
11157 return;
11158 }
11159 case HostRoot:
11160 {
11161 var _updateQueue = finishedWork.updateQueue;
11162 if (_updateQueue !== null) {
11163 var _instance2 = null;
11164 if (finishedWork.child !== null) {
11165 switch (finishedWork.child.tag) {
11166 case HostComponent:
11167 _instance2 = getPublicInstance(finishedWork.child.stateNode);
11168 break;
11169 case ClassComponent:
11170 _instance2 = finishedWork.child.stateNode;
11171 break;
11172 }
11173 }
11174 commitCallbacks(_updateQueue, _instance2);
11175 }
11176 return;
11177 }
11178 case HostComponent:
11179 {
11180 var _instance3 = finishedWork.stateNode;
11181
11182 // Renderers may schedule work to be done after host components are mounted
11183 // (eg DOM renderer may schedule auto-focus for inputs and form controls).
11184 // These effects should only be committed when components are first mounted,
11185 // aka when there is no current/alternate.
11186 if (current === null && finishedWork.effectTag & Update) {
11187 var type = finishedWork.type;
11188 var props = finishedWork.memoizedProps;

Callers 1

commitAllLifeCyclesFunction · 0.70

Calls 5

startPhaseTimerFunction · 0.70
stopPhaseTimerFunction · 0.70
commitCallbacksFunction · 0.70
invariantFunction · 0.70
componentDidMountMethod · 0.45

Tested by

no test coverage detected