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

Function commitWork

code/third-party/public/app.js:11049–11096  ·  view source on GitHub ↗
(current, finishedWork)

Source from the content-addressed store, hash-verified

11047 }
11048
11049 function commitWork(current, finishedWork) {
11050 switch (finishedWork.tag) {
11051 case ClassComponent:
11052 {
11053 return;
11054 }
11055 case HostComponent:
11056 {
11057 var _instance7 = finishedWork.stateNode;
11058 if (_instance7 != null) {
11059 // Commit the work prepared earlier.
11060 var newProps = finishedWork.memoizedProps;
11061 // For hydration we reuse the update path but we treat the oldProps
11062 // as the newProps. The updatePayload will contain the real change in
11063 // this case.
11064 var oldProps = current !== null ? current.memoizedProps : newProps;
11065 var type = finishedWork.type;
11066 // TODO: Type the updateQueue to be specific to host components.
11067 var updatePayload = finishedWork.updateQueue;
11068 finishedWork.updateQueue = null;
11069 if (updatePayload !== null) {
11070 commitUpdate(_instance7, updatePayload, type, oldProps, newProps, finishedWork);
11071 }
11072 }
11073 return;
11074 }
11075 case HostText:
11076 {
11077 !(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;
11078 var textInstance = finishedWork.stateNode;
11079 var newText = finishedWork.memoizedProps;
11080 // For hydration we reuse the update path but we treat the oldProps
11081 // as the newProps. The updatePayload will contain the real change in
11082 // this case.
11083 var oldText = current !== null ? current.memoizedProps : newText;
11084 commitTextUpdate(textInstance, oldText, newText);
11085 return;
11086 }
11087 case HostRoot:
11088 {
11089 return;
11090 }
11091 default:
11092 {
11093 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.');
11094 }
11095 }
11096 }
11097
11098 function commitResetTextContent(current) {
11099 resetTextContent(current.stateNode);

Callers 1

commitAllHostEffectsFunction · 0.70

Calls 1

invariantFunction · 0.70

Tested by

no test coverage detected