@@ -30,7 +30,7 @@ import {
3030 ContextProvider ,
3131 ContextConsumer ,
3232 Profiler ,
33- PlaceholderComponent ,
33+ SuspenseComponent ,
3434 PureComponent ,
3535 PureComponentLazy ,
3636} from 'shared/ReactWorkTags' ;
@@ -45,7 +45,6 @@ import {
4545} from 'shared/ReactSideEffectTags' ;
4646import ReactSharedInternals from 'shared/ReactSharedInternals' ;
4747import {
48- enableSuspense ,
4948 debugRenderPhaseSideEffects ,
5049 debugRenderPhaseSideEffectsForStrictMode ,
5150 enableProfilerTimer ,
@@ -935,77 +934,72 @@ function mountIndeterminateComponent(
935934 }
936935}
937936
938- function updatePlaceholderComponent (
937+ function updateSuspenseComponent (
939938 current ,
940939 workInProgress ,
941940 renderExpirationTime ,
942941) {
943- if ( enableSuspense ) {
944- const nextProps = workInProgress . pendingProps ;
945-
946- // Check if we already attempted to render the normal state. If we did,
947- // and we timed out, render the placeholder state.
948- const alreadyCaptured =
949- ( workInProgress . effectTag & DidCapture ) === NoEffect ;
950-
951- let nextDidTimeout ;
952- if ( current !== null && workInProgress . updateQueue !== null ) {
953- // We're outside strict mode. Something inside this Placeholder boundary
954- // suspended during the last commit. Switch to the placholder.
955- workInProgress . updateQueue = null ;
956- nextDidTimeout = true ;
957- } else {
958- nextDidTimeout = ! alreadyCaptured ;
959- }
942+ const nextProps = workInProgress . pendingProps ;
960943
961- if ( ( workInProgress . mode & StrictMode ) !== NoEffect ) {
962- if ( nextDidTimeout ) {
963- // If the timed-out view commits, schedule an update effect to record
964- // the committed time.
965- workInProgress . effectTag |= Update ;
966- } else {
967- // The state node points to the time at which placeholder timed out.
968- // We can clear it once we switch back to the normal children.
969- workInProgress . stateNode = null ;
970- }
971- }
944+ // Check if we already attempted to render the normal state. If we did,
945+ // and we timed out, render the placeholder state.
946+ const alreadyCaptured = ( workInProgress . effectTag & DidCapture ) === NoEffect ;
972947
973- // If the `children` prop is a function, treat it like a render prop.
974- // TODO: This is temporary until we finalize a lower level API.
975- const children = nextProps . children ;
976- let nextChildren ;
977- if ( typeof children === 'function' ) {
978- nextChildren = children ( nextDidTimeout ) ;
979- } else {
980- nextChildren = nextDidTimeout ? nextProps . fallback : children ;
981- }
948+ let nextDidTimeout ;
949+ if ( current !== null && workInProgress . updateQueue !== null ) {
950+ // We're outside strict mode. Something inside this Placeholder boundary
951+ // suspended during the last commit. Switch to the placholder.
952+ workInProgress . updateQueue = null ;
953+ nextDidTimeout = true ;
954+ } else {
955+ nextDidTimeout = ! alreadyCaptured ;
956+ }
982957
983- if ( current !== null && nextDidTimeout !== workInProgress . memoizedState ) {
984- // We're about to switch from the placeholder children to the normal
985- // children, or vice versa. These are two different conceptual sets that
986- // happen to be stored in the same set. Call this special function to
987- // force the new set not to match with the current set.
988- // TODO: The proper way to model this is by storing each set separately.
989- forceUnmountCurrentAndReconcile (
990- current ,
991- workInProgress ,
992- nextChildren ,
993- renderExpirationTime ,
994- ) ;
958+ if ( ( workInProgress . mode & StrictMode ) !== NoEffect ) {
959+ if ( nextDidTimeout ) {
960+ // If the timed-out view commits, schedule an update effect to record
961+ // the committed time.
962+ workInProgress . effectTag |= Update ;
995963 } else {
996- reconcileChildren (
997- current ,
998- workInProgress ,
999- nextChildren ,
1000- renderExpirationTime ,
1001- ) ;
964+ // The state node points to the time at which placeholder timed out.
965+ // We can clear it once we switch back to the normal children.
966+ workInProgress . stateNode = null ;
1002967 }
1003- workInProgress . memoizedProps = nextProps ;
1004- workInProgress . memoizedState = nextDidTimeout ;
1005- return workInProgress . child ;
968+ }
969+
970+ // If the `children` prop is a function, treat it like a render prop.
971+ // TODO: This is temporary until we finalize a lower level API.
972+ const children = nextProps . children ;
973+ let nextChildren ;
974+ if ( typeof children === 'function' ) {
975+ nextChildren = children ( nextDidTimeout ) ;
1006976 } else {
1007- return null ;
977+ nextChildren = nextDidTimeout ? nextProps . fallback : children ;
978+ }
979+
980+ if ( current !== null && nextDidTimeout !== workInProgress . memoizedState ) {
981+ // We're about to switch from the placeholder children to the normal
982+ // children, or vice versa. These are two different conceptual sets that
983+ // happen to be stored in the same set. Call this special function to
984+ // force the new set not to match with the current set.
985+ // TODO: The proper way to model this is by storing each set separately.
986+ forceUnmountCurrentAndReconcile (
987+ current ,
988+ workInProgress ,
989+ nextChildren ,
990+ renderExpirationTime ,
991+ ) ;
992+ } else {
993+ reconcileChildren (
994+ current ,
995+ workInProgress ,
996+ nextChildren ,
997+ renderExpirationTime ,
998+ ) ;
1008999 }
1000+ workInProgress . memoizedProps = nextProps ;
1001+ workInProgress . memoizedState = nextDidTimeout ;
1002+ return workInProgress . child ;
10091003}
10101004
10111005function updatePortalComponent (
@@ -1342,8 +1336,8 @@ function beginWork(
13421336 return updateHostComponent(current, workInProgress, renderExpirationTime);
13431337 case HostText:
13441338 return updateHostText(current, workInProgress);
1345- case PlaceholderComponent :
1346- return updatePlaceholderComponent (
1339+ case SuspenseComponent :
1340+ return updateSuspenseComponent (
13471341 current,
13481342 workInProgress,
13491343 renderExpirationTime,
0 commit comments