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

Function commitWork

code/redux/public/app.js:12067–12114  ·  view source on GitHub ↗
(current, finishedWork)

Source from the content-addressed store, hash-verified

12065 }
12066
12067 function commitWork(current, finishedWork) {
12068 switch (finishedWork.tag) {
12069 case ClassComponent:
12070 {
12071 return;
12072 }
12073 case HostComponent:
12074 {
12075 var _instance7 = finishedWork.stateNode;
12076 if (_instance7 != null) {
12077 // Commit the work prepared earlier.
12078 var newProps = finishedWork.memoizedProps;
12079 // For hydration we reuse the update path but we treat the oldProps
12080 // as the newProps. The updatePayload will contain the real change in
12081 // this case.
12082 var oldProps = current !== null ? current.memoizedProps : newProps;
12083 var type = finishedWork.type;
12084 // TODO: Type the updateQueue to be specific to host components.
12085 var updatePayload = finishedWork.updateQueue;
12086 finishedWork.updateQueue = null;
12087 if (updatePayload !== null) {
12088 commitUpdate(_instance7, updatePayload, type, oldProps, newProps, finishedWork);
12089 }
12090 }
12091 return;
12092 }
12093 case HostText:
12094 {
12095 !(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;
12096 var textInstance = finishedWork.stateNode;
12097 var newText = finishedWork.memoizedProps;
12098 // For hydration we reuse the update path but we treat the oldProps
12099 // as the newProps. The updatePayload will contain the real change in
12100 // this case.
12101 var oldText = current !== null ? current.memoizedProps : newText;
12102 commitTextUpdate(textInstance, oldText, newText);
12103 return;
12104 }
12105 case HostRoot:
12106 {
12107 return;
12108 }
12109 default:
12110 {
12111 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.');
12112 }
12113 }
12114 }
12115
12116 function commitResetTextContent(current) {
12117 resetTextContent(current.stateNode);

Callers 1

commitAllHostEffectsFunction · 0.70

Calls 1

invariantFunction · 0.70

Tested by

no test coverage detected