@@ -992,7 +992,7 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
992
992
993
993
// Read the current time from the host environment.
994
994
const currentTime = recalculateCurrentTime ( ) ;
995
- const minExpirationTime = priorityToExpirationTime (
995
+ const minExpirationTime = getExpirationTimeForPriority (
996
996
currentTime ,
997
997
minPriorityLevel ,
998
998
) ;
@@ -1447,30 +1447,36 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
1447
1447
const root : FiberRoot = ( node . stateNode : any ) ;
1448
1448
scheduleRoot ( root , expirationTime ) ;
1449
1449
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
+ }
1474
1480
}
1475
1481
}
1476
1482
} else {
@@ -1533,11 +1539,11 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
1533
1539
}
1534
1540
1535
1541
function scheduleErrorRecovery ( fiber : Fiber ) {
1536
- scheduleUpdateImpl (
1537
- fiber ,
1538
- priorityToExpirationTime ( mostRecentCurrentTime , TaskPriority ) ,
1539
- true ,
1542
+ const taskTime = getExpirationTimeForPriority (
1543
+ mostRecentCurrentTime ,
1544
+ TaskPriority ,
1540
1545
) ;
1546
+ scheduleUpdateImpl ( fiber , taskTime , true ) ;
1541
1547
}
1542
1548
1543
1549
function recalculateCurrentTime ( ) : ExpirationTime {
0 commit comments