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

Function commitWork

code/one-direction-data-flow/public/app.js:11689–11736  ·  view source on GitHub ↗
(current, finishedWork)

Source from the content-addressed store, hash-verified

11687 }
11688
11689 function commitWork(current, finishedWork) {
11690 switch (finishedWork.tag) {
11691 case ClassComponent:
11692 {
11693 return;
11694 }
11695 case HostComponent:
11696 {
11697 var _instance7 = finishedWork.stateNode;
11698 if (_instance7 != null) {
11699 // Commit the work prepared earlier.
11700 var newProps = finishedWork.memoizedProps;
11701 // For hydration we reuse the update path but we treat the oldProps
11702 // as the newProps. The updatePayload will contain the real change in
11703 // this case.
11704 var oldProps = current !== null ? current.memoizedProps : newProps;
11705 var type = finishedWork.type;
11706 // TODO: Type the updateQueue to be specific to host components.
11707 var updatePayload = finishedWork.updateQueue;
11708 finishedWork.updateQueue = null;
11709 if (updatePayload !== null) {
11710 commitUpdate(_instance7, updatePayload, type, oldProps, newProps, finishedWork);
11711 }
11712 }
11713 return;
11714 }
11715 case HostText:
11716 {
11717 !(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;
11718 var textInstance = finishedWork.stateNode;
11719 var newText = finishedWork.memoizedProps;
11720 // For hydration we reuse the update path but we treat the oldProps
11721 // as the newProps. The updatePayload will contain the real change in
11722 // this case.
11723 var oldText = current !== null ? current.memoizedProps : newText;
11724 commitTextUpdate(textInstance, oldText, newText);
11725 return;
11726 }
11727 case HostRoot:
11728 {
11729 return;
11730 }
11731 default:
11732 {
11733 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.');
11734 }
11735 }
11736 }
11737
11738 function commitResetTextContent(current) {
11739 resetTextContent(current.stateNode);

Callers 1

commitAllHostEffectsFunction · 0.70

Calls 1

invariantFunction · 0.70

Tested by

no test coverage detected