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

Function commitWork

code/event-handlers/public/app.js:11146–11193  ·  view source on GitHub ↗
(current, finishedWork)

Source from the content-addressed store, hash-verified

11144 }
11145
11146 function commitWork(current, finishedWork) {
11147 switch (finishedWork.tag) {
11148 case ClassComponent:
11149 {
11150 return;
11151 }
11152 case HostComponent:
11153 {
11154 var _instance7 = finishedWork.stateNode;
11155 if (_instance7 != null) {
11156 // Commit the work prepared earlier.
11157 var newProps = finishedWork.memoizedProps;
11158 // For hydration we reuse the update path but we treat the oldProps
11159 // as the newProps. The updatePayload will contain the real change in
11160 // this case.
11161 var oldProps = current !== null ? current.memoizedProps : newProps;
11162 var type = finishedWork.type;
11163 // TODO: Type the updateQueue to be specific to host components.
11164 var updatePayload = finishedWork.updateQueue;
11165 finishedWork.updateQueue = null;
11166 if (updatePayload !== null) {
11167 commitUpdate(_instance7, updatePayload, type, oldProps, newProps, finishedWork);
11168 }
11169 }
11170 return;
11171 }
11172 case HostText:
11173 {
11174 !(finishedWork.stateNode !== null) ? invariant(false, 'This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue.') : void 0;
11175 var textInstance = finishedWork.stateNode;
11176 var newText = finishedWork.memoizedProps;
11177 // For hydration we reuse the update path but we treat the oldProps
11178 // as the newProps. The updatePayload will contain the real change in
11179 // this case.
11180 var oldText = current !== null ? current.memoizedProps : newText;
11181 commitTextUpdate(textInstance, oldText, newText);
11182 return;
11183 }
11184 case HostRoot:
11185 {
11186 return;
11187 }
11188 default:
11189 {
11190 invariant(false, 'This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.');
11191 }
11192 }
11193 }
11194
11195 function commitResetTextContent(current) {
11196 resetTextContent(current.stateNode);

Callers 1

commitAllHostEffectsFunction · 0.70

Calls 1

invariantFunction · 0.70

Tested by

no test coverage detected