MCPcopy Index your code
hub / github.com/react/react / reappearLayoutEffects

Function reappearLayoutEffects

packages/react-reconciler/src/ReactFiberCommitWork.js:3029–3254  ·  view source on GitHub ↗
(
  finishedRoot: FiberRoot,
  current: Fiber | null,
  finishedWork: Fiber,
  // This function visits both newly finished work and nodes that were re-used
  // from a previously committed tree. We cannot check non-static flags if the
  // node was reused.
  includeWorkInProgressEffects: boolean,
)

Source from the content-addressed store, hash-verified

3027}
3028
3029export function reappearLayoutEffects(
3030 finishedRoot: FiberRoot,
3031 current: Fiber | null,
3032 finishedWork: Fiber,
3033 // This function visits both newly finished work and nodes that were re-used
3034 // from a previously committed tree. We cannot check non-static flags if the
3035 // node was reused.
3036 includeWorkInProgressEffects: boolean,
3037) {
3038 const prevEffectStart = pushComponentEffectStart();
3039 const prevEffectDuration = pushComponentEffectDuration();
3040 const prevEffectErrors = pushComponentEffectErrors();
3041 const prevEffectDidSpawnUpdate = pushComponentEffectDidSpawnUpdate();
3042 // Turn on layout effects in a tree that previously disappeared.
3043 const flags = finishedWork.flags;
3044 switch (finishedWork.tag) {
3045 case FunctionComponent:
3046 case ForwardRef:
3047 case SimpleMemoComponent: {
3048 recursivelyTraverseReappearLayoutEffects(
3049 finishedRoot,
3050 finishedWork,
3051 includeWorkInProgressEffects,
3052 );
3053 // TODO: Check flags & LayoutStatic
3054 commitHookLayoutEffects(finishedWork, HookLayout);
3055 break;
3056 }
3057 case ClassComponent: {
3058 recursivelyTraverseReappearLayoutEffects(
3059 finishedRoot,
3060 finishedWork,
3061 includeWorkInProgressEffects,
3062 );
3063
3064 commitClassDidMount(finishedWork);
3065
3066 commitClassHiddenCallbacks(finishedWork);
3067
3068 // If this is newly finished work, check for setState callbacks
3069 if (includeWorkInProgressEffects && flags & Callback) {
3070 commitClassCallbacks(finishedWork);
3071 }
3072
3073 // TODO: Check flags & RefStatic
3074 safelyAttachRef(finishedWork, finishedWork.return);
3075 break;
3076 }
3077 // Unlike commitLayoutEffectsOnFiber, we don't need to handle HostRoot
3078 // because this function only visits nodes that are inside an
3079 // Offscreen fiber.
3080 // case HostRoot: {
3081 // ...
3082 // }
3083 case HostSingleton: {
3084 if (supportsSingletons) {
3085 // We acquire the singleton instance first so it has appropriate
3086 // styles before other layout effects run. This isn't perfect because

Calls 15

pushComponentEffectStartFunction · 0.90
commitHookLayoutEffectsFunction · 0.90
commitClassDidMountFunction · 0.90
commitClassCallbacksFunction · 0.90
safelyAttachRefFunction · 0.90
commitHostMountFunction · 0.90

Tested by

no test coverage detected