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

Function replayBeginWork

packages/react-reconciler/src/ReactFiberWorkLoop.js:3053–3137  ·  view source on GitHub ↗
(unitOfWork: Fiber)

Source from the content-addressed store, hash-verified

3051}
3052
3053function replayBeginWork(unitOfWork: Fiber): null | Fiber {
3054 // This is a fork of beginWork specifcally for replaying a fiber that
3055 // just suspended.
3056
3057 const current = unitOfWork.alternate;
3058
3059 let next;
3060 const isProfilingMode =
3061 enableProfilerTimer && (unitOfWork.mode & ProfileMode) !== NoMode;
3062 if (isProfilingMode) {
3063 startProfilerTimer(unitOfWork);
3064 }
3065 switch (unitOfWork.tag) {
3066 case SimpleMemoComponent:
3067 case FunctionComponent: {
3068 // Resolve `defaultProps`. This logic is copied from `beginWork`.
3069 // TODO: Consider moving this switch statement into that module. Also,
3070 // could maybe use this as an opportunity to say `use` doesn't work with
3071 // `defaultProps` :)
3072 const Component = unitOfWork.type;
3073 let context: any;
3074 if (!disableLegacyContext) {
3075 const unmaskedContext = getUnmaskedContext(unitOfWork, Component, true);
3076 context = getMaskedContext(unitOfWork, unmaskedContext);
3077 }
3078 next = replayFunctionComponent(
3079 current,
3080 unitOfWork,
3081 unitOfWork.pendingProps,
3082 Component,
3083 context,
3084 workInProgressRootRenderLanes,
3085 );
3086 break;
3087 }
3088 case ForwardRef: {
3089 // Resolve `defaultProps`. This logic is copied from `beginWork`.
3090 // TODO: Consider moving this switch statement into that module. Also,
3091 // could maybe use this as an opportunity to say `use` doesn't work with
3092 // `defaultProps` :)
3093 const Component = unitOfWork.type.render;
3094 next = replayFunctionComponent(
3095 current,
3096 unitOfWork,
3097 unitOfWork.pendingProps,
3098 Component,
3099 unitOfWork.ref,
3100 workInProgressRootRenderLanes,
3101 );
3102 break;
3103 }
3104 case HostComponent: {
3105 // Some host components are stateful (that's how we implement form
3106 // actions) but we don't bother to reuse the memoized state because it's
3107 // not worth the extra code. The main reason to reuse the previous hooks
3108 // is to reuse uncached promises, but we happen to know that the only
3109 // promises that a host component might suspend on are definitely cached
3110 // because they are controlled by us. So don't bother.

Callers 1

Calls 8

startProfilerTimerFunction · 0.90
getUnmaskedContextFunction · 0.90
getMaskedContextFunction · 0.90
replayFunctionComponentFunction · 0.90
unwindInterruptedWorkFunction · 0.90
resetWorkInProgressFunction · 0.90
beginWorkFunction · 0.90

Tested by

no test coverage detected