@@ -64,11 +64,7 @@ import {
6464 reconcileChildFibers ,
6565 cloneChildFibers ,
6666} from './ReactChildFiber' ;
67- import {
68- createUpdate ,
69- enqueueCapturedUpdate ,
70- processUpdateQueue ,
71- } from './ReactUpdateQueue' ;
67+ import { processUpdateQueue } from './ReactUpdateQueue' ;
7268import { NoWork , Never } from './ReactFiberExpirationTime' ;
7369import { AsyncMode , StrictMode } from './ReactTypeOfMode' ;
7470import MAX_SIGNED_31_BIT_INT from './maxSigned31BitInt' ;
@@ -734,33 +730,34 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
734730 const nextProps = workInProgress . pendingProps ;
735731 const prevProps = workInProgress . memoizedProps ;
736732
737- // Unless we already captured a promise during this render, reset the
738- // placeholder state back to false. We always attempt to render the real
739- // children before falling back to the placeholder.
740- if ( ( workInProgress . effectTag & DidCapture ) === NoEffect ) {
741- const update = createUpdate ( renderExpirationTime ) ;
742- update . process = ( ) => false ;
743- enqueueCapturedUpdate ( workInProgress , update , renderExpirationTime ) ;
744- }
733+ const prevDidTimeout = workInProgress . memoizedState ;
745734
746- const prevState = workInProgress . memoizedState ;
735+ // The update queue is only used to store expired promises, and to
736+ // schedule a re-render once an expired promise resolves. It does not
737+ // determine whether we should show the placeholder state, because we
738+ // always attempt to show the placeholder state on every render.
747739 const updateQueue = workInProgress . updateQueue ;
748740 if ( updateQueue !== null ) {
749741 processUpdateQueue ( workInProgress , updateQueue , renderExpirationTime ) ;
750742 }
751- const nextState = workInProgress . memoizedState ;
743+
744+ // Check if we already attempted to render the normal state. If we did,
745+ // and we timed out, render the placeholder state.
746+ const alreadyCaptured =
747+ ( workInProgress . effectTag & DidCapture ) === NoEffect ;
748+ const nextDidTimeout = ! alreadyCaptured ;
752749
753750 if ( hasLegacyContextChanged ( ) ) {
754751 // Normally we can bail out on props equality but if context has changed
755752 // we don't do the bailout and we have to reuse existing props instead.
756- } else if ( nextProps === prevProps && nextState === prevState ) {
753+ } else if ( nextProps === prevProps && nextDidTimeout === prevDidTimeout ) {
757754 return bailoutOnAlreadyFinishedWork ( current , workInProgress ) ;
758755 }
759756
760- const didTimeout = nextState ;
761757 const render = nextProps . children ;
762- const nextChildren = render ( didTimeout ) ;
758+ const nextChildren = render ( nextDidTimeout ) ;
763759 workInProgress . memoizedProps = nextProps ;
760+ workInProgress . memoizedState = nextDidTimeout ;
764761 reconcileChildren ( current , workInProgress , nextChildren ) ;
765762 return workInProgress . child ;
766763 } else {
0 commit comments