@@ -465,6 +465,52 @@ function updateForwardRef(
465465 return workInProgress . child ;
466466}
467467
468+ export function replayForwardRef (
469+ current : Fiber | null ,
470+ workInProgress : Fiber ,
471+ nextProps : any ,
472+ Component : any ,
473+ renderLanes : Lanes ,
474+ ) : Fiber | null {
475+ const secondArg = workInProgress . ref ;
476+
477+ // This function is used to replay a component that previously suspended,
478+ // after its data resolves. It's a simplified version of
479+ // updateFunctionComponent that reuses the hooks from the previous attempt.
480+
481+ prepareToReadContext ( workInProgress , renderLanes ) ;
482+ if ( enableSchedulingProfiler ) {
483+ markComponentRenderStarted ( workInProgress ) ;
484+ }
485+ const nextChildren = replaySuspendedComponentWithHooks (
486+ current ,
487+ workInProgress ,
488+ Component ,
489+ nextProps ,
490+ secondArg ,
491+ ) ;
492+
493+ // the rest is a fork of updateFunctionComponent
494+ const hasId = checkDidRenderIdHook ( ) ;
495+ if ( enableSchedulingProfiler ) {
496+ markComponentRenderStopped ( ) ;
497+ }
498+
499+ if ( current !== null && ! didReceiveUpdate ) {
500+ bailoutHooks ( current , workInProgress , renderLanes ) ;
501+ return bailoutOnAlreadyFinishedWork ( current , workInProgress , renderLanes ) ;
502+ }
503+
504+ if ( getIsHydrating ( ) && hasId ) {
505+ pushMaterializedTreeId ( workInProgress ) ;
506+ }
507+
508+ // React DevTools reads this flag.
509+ workInProgress . flags |= PerformedWork ;
510+ reconcileChildren ( current , workInProgress , nextChildren , renderLanes ) ;
511+ return workInProgress . child ;
512+ }
513+
468514function updateMemoComponent (
469515 current : Fiber | null ,
470516 workInProgress : Fiber ,
@@ -1169,15 +1215,15 @@ export function replayFunctionComponent(
11691215 nextProps : any ,
11701216 Component : any ,
11711217 renderLanes : Lanes ,
1172- secondArg : any ,
11731218) : Fiber | null {
11741219 // This function is used to replay a component that previously suspended,
11751220 // after its data resolves. It's a simplified version of
11761221 // updateFunctionComponent that reuses the hooks from the previous attempt.
11771222
1178- if ( ! disableLegacyContext && secondArg === undefined ) {
1223+ let context : any ;
1224+ if ( ! disableLegacyContext ) {
11791225 const unmaskedContext = getUnmaskedContext ( workInProgress , Component , true ) ;
1180- secondArg = getMaskedContext ( workInProgress , unmaskedContext ) ;
1226+ context = getMaskedContext ( workInProgress , unmaskedContext ) ;
11811227 }
11821228
11831229 prepareToReadContext ( workInProgress , renderLanes ) ;
@@ -1189,7 +1235,7 @@ export function replayFunctionComponent(
11891235 workInProgress ,
11901236 Component ,
11911237 nextProps ,
1192- secondArg ,
1238+ context ,
11931239 ) ;
11941240 const hasId = checkDidRenderIdHook ( ) ;
11951241 if ( enableSchedulingProfiler ) {
0 commit comments