MCPcopy
hub / github.com/facebook/react / completeWork

Function completeWork

packages/react-reconciler/src/ReactFiberCompleteWork.js:1049–2040  ·  view source on GitHub ↗
(
  current: Fiber | null,
  workInProgress: Fiber,
  renderLanes: Lanes,
)

Source from the content-addressed store, hash-verified

1047}
1048
1049function completeWork(
1050 current: Fiber | null,
1051 workInProgress: Fiber,
1052 renderLanes: Lanes,
1053): Fiber | null {
1054 const newProps = workInProgress.pendingProps;
1055 // Note: This intentionally doesn't check if we're hydrating because comparing
1056 // to the current tree provider fiber is just as fast and less error-prone.
1057 // Ideally we would have a special version of the work loop only
1058 // for hydration.
1059 popTreeContext(workInProgress);
1060 switch (workInProgress.tag) {
1061 case IncompleteFunctionComponent: {
1062 if (disableLegacyMode) {
1063 break;
1064 }
1065 // Fallthrough
1066 }
1067 case LazyComponent:
1068 case SimpleMemoComponent:
1069 case FunctionComponent:
1070 case ForwardRef:
1071 case Fragment:
1072 case Mode:
1073 case Profiler:
1074 case ContextConsumer:
1075 case MemoComponent:
1076 bubbleProperties(workInProgress);
1077 return null;
1078 case ClassComponent: {
1079 const Component = workInProgress.type;
1080 if (isLegacyContextProvider(Component)) {
1081 popLegacyContext(workInProgress);
1082 }
1083 bubbleProperties(workInProgress);
1084 return null;
1085 }
1086 case HostRoot: {
1087 const fiberRoot = (workInProgress.stateNode: FiberRoot);
1088
1089 if (enableTransitionTracing) {
1090 const transitions = getWorkInProgressTransitions();
1091 // We set the Passive flag here because if there are new transitions,
1092 // we will need to schedule callbacks and process the transitions,
1093 // which we do in the passive phase
1094 if (transitions !== null) {
1095 workInProgress.flags |= Passive;
1096 }
1097 }
1098
1099 let previousCache: Cache | null = null;
1100 if (current !== null) {
1101 previousCache = current.memoizedState.cache;
1102 }
1103 const cache: Cache = workInProgress.memoizedState.cache;
1104 if (cache !== previousCache) {
1105 // Run passive effects to retain/release the cache.
1106 workInProgress.flags |= Passive;

Callers 1

completeUnitOfWorkFunction · 0.90

Calls 15

popTreeContextFunction · 0.90
popCacheProviderFunction · 0.90
popRootMarkerInstanceFunction · 0.90
popRootTransitionFunction · 0.90
popHostContainerFunction · 0.90
popHydrationStateFunction · 0.90
popHostContextFunction · 0.90
getRootHostContainerFunction · 0.90
getHostContextFunction · 0.90

Tested by

no test coverage detected