@@ -992,7 +992,7 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
992992
993993 // Read the current time from the host environment.
994994 const currentTime = recalculateCurrentTime ( ) ;
995- const minExpirationTime = priorityToExpirationTime (
995+ const minExpirationTime = getExpirationTimeForPriority (
996996 currentTime ,
997997 minPriorityLevel ,
998998 ) ;
@@ -1447,30 +1447,36 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
14471447 const root : FiberRoot = ( node . stateNode : any ) ;
14481448 scheduleRoot ( root , expirationTime ) ;
14491449 if ( ! isPerformingWork ) {
1450- if ( expirationTime < mostRecentCurrentTime ) {
1451- // This update is synchronous. Perform it now.
1452- if ( isUnbatchingUpdates ) {
1453- // We're inside unbatchedUpdates, which is inside either
1454- // batchedUpdates or a lifecycle. We should only flush
1455- // synchronous work, not task work.
1456- performWork ( SynchronousPriority , null ) ;
1457- } else {
1458- // Flush both synchronous and task work.
1459- performWork ( TaskPriority , null ) ;
1460- }
1461- } else if ( expirationTime === mostRecentCurrentTime ) {
1462- invariant (
1463- isBatchingUpdates ,
1464- 'Task updates can only be scheduled as a nested update or ' +
1465- 'inside batchedUpdates. This error is likely caused by a ' +
1466- 'bug in React. Please file an issue.' ,
1467- ) ;
1468- } else {
1469- // This update is async. Schedule a callback.
1470- if ( ! isCallbackScheduled ) {
1471- scheduleDeferredCallback ( performDeferredWork ) ;
1472- isCallbackScheduled = true ;
1473- }
1450+ const priorityLevel = expirationTimeToPriorityLevel (
1451+ mostRecentCurrentTime ,
1452+ expirationTime ,
1453+ ) ;
1454+ switch ( priorityLevel ) {
1455+ case SynchronousPriority :
1456+ if ( isUnbatchingUpdates ) {
1457+ // We're inside unbatchedUpdates, which is inside either
1458+ // batchedUpdates or a lifecycle. We should only flush
1459+ // synchronous work, not task work.
1460+ performWork ( SynchronousPriority , null ) ;
1461+ } else {
1462+ // Flush both synchronous and task work.
1463+ performWork ( TaskPriority , null ) ;
1464+ }
1465+ break ;
1466+ case TaskPriority :
1467+ invariant (
1468+ isBatchingUpdates ,
1469+ 'Task updates can only be scheduled as a nested update or ' +
1470+ 'inside batchedUpdates. This error is likely caused by a ' +
1471+ 'bug in React. Please file an issue.' ,
1472+ ) ;
1473+ break ;
1474+ default :
1475+ // This update is async. Schedule a callback.
1476+ if ( ! isCallbackScheduled ) {
1477+ scheduleDeferredCallback ( performDeferredWork ) ;
1478+ isCallbackScheduled = true ;
1479+ }
14741480 }
14751481 }
14761482 } else {
@@ -1533,11 +1539,11 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
15331539 }
15341540
15351541 function scheduleErrorRecovery ( fiber : Fiber ) {
1536- scheduleUpdateImpl (
1537- fiber ,
1538- priorityToExpirationTime ( mostRecentCurrentTime , TaskPriority ) ,
1539- true ,
1542+ const taskTime = getExpirationTimeForPriority (
1543+ mostRecentCurrentTime ,
1544+ TaskPriority ,
15401545 ) ;
1546+ scheduleUpdateImpl ( fiber , taskTime , true ) ;
15411547 }
15421548
15431549 function recalculateCurrentTime ( ) : ExpirationTime {
0 commit comments