MCPcopy Create free account
hub / github.com/reactjs/react-rails / commitWork

Function commitWork

lib/assets/react-source/development/react.js:24201–24310  ·  view source on GitHub ↗
(current, finishedWork)

Source from the content-addressed store, hash-verified

24199 }
24200
24201 function commitWork(current, finishedWork) {
24202
24203 switch (finishedWork.tag) {
24204 case FunctionComponent:
24205 case ForwardRef:
24206 case MemoComponent:
24207 case SimpleMemoComponent:
24208 case Block:
24209 {
24210 // Layout effects are destroyed during the mutation phase so that all
24211 // destroy functions for all fibers are called before any create functions.
24212 // This prevents sibling component effects from interfering with each other,
24213 // e.g. a destroy function in one component should never override a ref set
24214 // by a create function in another component during the same commit.
24215 commitHookEffectListUnmount(Layout | HasEffect, finishedWork);
24216 return;
24217 }
24218
24219 case ClassComponent:
24220 {
24221 return;
24222 }
24223
24224 case HostComponent:
24225 {
24226 var instance = finishedWork.stateNode;
24227
24228 if (instance != null) {
24229 // Commit the work prepared earlier.
24230 var newProps = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps
24231 // as the newProps. The updatePayload will contain the real change in
24232 // this case.
24233
24234 var oldProps = current !== null ? current.memoizedProps : newProps;
24235 var type = finishedWork.type; // TODO: Type the updateQueue to be specific to host components.
24236
24237 var updatePayload = finishedWork.updateQueue;
24238 finishedWork.updateQueue = null;
24239
24240 if (updatePayload !== null) {
24241 commitUpdate(instance, updatePayload, type, oldProps, newProps);
24242 }
24243 }
24244
24245 return;
24246 }
24247
24248 case HostText:
24249 {
24250 if (!(finishedWork.stateNode !== null)) {
24251 {
24252 throw Error( "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." );
24253 }
24254 }
24255
24256 var textInstance = finishedWork.stateNode;
24257 var newText = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps
24258 // as the newProps. The updatePayload will contain the real change in

Callers 1

commitMutationEffectsFunction · 0.85

Calls 6

commitUpdateFunction · 0.85
commitTextUpdateFunction · 0.85
commitHydratedContainerFunction · 0.85
commitSuspenseComponentFunction · 0.85

Tested by

no test coverage detected