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

Function commitWork

code/new-context-api/public/app.js:11177–11224  ·  view source on GitHub ↗
(current, finishedWork)

Source from the content-addressed store, hash-verified

11175 }
11176
11177 function commitWork(current, finishedWork) {
11178 switch (finishedWork.tag) {
11179 case ClassComponent:
11180 {
11181 return;
11182 }
11183 case HostComponent:
11184 {
11185 var _instance7 = finishedWork.stateNode;
11186 if (_instance7 != null) {
11187 // Commit the work prepared earlier.
11188 var newProps = finishedWork.memoizedProps;
11189 // For hydration we reuse the update path but we treat the oldProps
11190 // as the newProps. The updatePayload will contain the real change in
11191 // this case.
11192 var oldProps = current !== null ? current.memoizedProps : newProps;
11193 var type = finishedWork.type;
11194 // TODO: Type the updateQueue to be specific to host components.
11195 var updatePayload = finishedWork.updateQueue;
11196 finishedWork.updateQueue = null;
11197 if (updatePayload !== null) {
11198 commitUpdate(_instance7, updatePayload, type, oldProps, newProps, finishedWork);
11199 }
11200 }
11201 return;
11202 }
11203 case HostText:
11204 {
11205 !(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;
11206 var textInstance = finishedWork.stateNode;
11207 var newText = finishedWork.memoizedProps;
11208 // For hydration we reuse the update path but we treat the oldProps
11209 // as the newProps. The updatePayload will contain the real change in
11210 // this case.
11211 var oldText = current !== null ? current.memoizedProps : newText;
11212 commitTextUpdate(textInstance, oldText, newText);
11213 return;
11214 }
11215 case HostRoot:
11216 {
11217 return;
11218 }
11219 default:
11220 {
11221 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.');
11222 }
11223 }
11224 }
11225
11226 function commitResetTextContent(current) {
11227 resetTextContent(current.stateNode);

Callers 1

commitAllHostEffectsFunction · 0.70

Calls 1

invariantFunction · 0.70

Tested by

no test coverage detected