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

Function commitWork

code/controlled-uncontrolled/public/app.js:11140–11187  ·  view source on GitHub ↗
(current, finishedWork)

Source from the content-addressed store, hash-verified

11138 }
11139
11140 function commitWork(current, finishedWork) {
11141 switch (finishedWork.tag) {
11142 case ClassComponent:
11143 {
11144 return;
11145 }
11146 case HostComponent:
11147 {
11148 var _instance7 = finishedWork.stateNode;
11149 if (_instance7 != null) {
11150 // Commit the work prepared earlier.
11151 var newProps = finishedWork.memoizedProps;
11152 // For hydration we reuse the update path but we treat the oldProps
11153 // as the newProps. The updatePayload will contain the real change in
11154 // this case.
11155 var oldProps = current !== null ? current.memoizedProps : newProps;
11156 var type = finishedWork.type;
11157 // TODO: Type the updateQueue to be specific to host components.
11158 var updatePayload = finishedWork.updateQueue;
11159 finishedWork.updateQueue = null;
11160 if (updatePayload !== null) {
11161 commitUpdate(_instance7, updatePayload, type, oldProps, newProps, finishedWork);
11162 }
11163 }
11164 return;
11165 }
11166 case HostText:
11167 {
11168 !(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;
11169 var textInstance = finishedWork.stateNode;
11170 var newText = finishedWork.memoizedProps;
11171 // For hydration we reuse the update path but we treat the oldProps
11172 // as the newProps. The updatePayload will contain the real change in
11173 // this case.
11174 var oldText = current !== null ? current.memoizedProps : newText;
11175 commitTextUpdate(textInstance, oldText, newText);
11176 return;
11177 }
11178 case HostRoot:
11179 {
11180 return;
11181 }
11182 default:
11183 {
11184 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.');
11185 }
11186 }
11187 }
11188
11189 function commitResetTextContent(current) {
11190 resetTextContent(current.stateNode);

Callers 1

commitAllHostEffectsFunction · 0.70

Calls 1

invariantFunction · 0.70

Tested by

no test coverage detected