@@ -26,6 +26,7 @@ import {
2626 enableDebugTracing ,
2727 enableSchedulingProfiler ,
2828 enableNewReconciler ,
29+ decoupleUpdatePriorityFromScheduler ,
2930} from 'shared/ReactFeatureFlags' ;
3031
3132import { NoMode , BlockingMode , DebugTracingMode } from './ReactTypeOfMode' ;
@@ -1506,34 +1507,64 @@ function rerenderDeferredValue<T>(
15061507
15071508function startTransition(setPending, config, callback) {
15081509 const priorityLevel = getCurrentPriorityLevel ( ) ;
1509- const previousLanePriority = getCurrentUpdateLanePriority ( ) ;
1510- setCurrentUpdateLanePriority (
1511- higherLanePriority ( previousLanePriority , InputContinuousLanePriority ) ,
1512- ) ;
1513- runWithPriority (
1514- priorityLevel < UserBlockingPriority ? UserBlockingPriority : priorityLevel ,
1515- ( ) => {
1516- setPending ( true ) ;
1517- } ,
1518- ) ;
1510+ if ( decoupleUpdatePriorityFromScheduler ) {
1511+ const previousLanePriority = getCurrentUpdateLanePriority ( ) ;
1512+ setCurrentUpdateLanePriority (
1513+ higherLanePriority ( previousLanePriority , InputContinuousLanePriority ) ,
1514+ ) ;
15191515
1520- // If there's no SuspenseConfig set, we'll use the DefaultLanePriority for this transition.
1521- setCurrentUpdateLanePriority ( DefaultLanePriority ) ;
1516+ runWithPriority (
1517+ priorityLevel < UserBlockingPriority
1518+ ? UserBlockingPriority
1519+ : priorityLevel ,
1520+ ( ) => {
1521+ setPending ( true ) ;
1522+ } ,
1523+ ) ;
15221524
1523- runWithPriority (
1524- priorityLevel > NormalPriority ? NormalPriority : priorityLevel ,
1525- ( ) => {
1526- const previousConfig = ReactCurrentBatchConfig . suspense ;
1527- ReactCurrentBatchConfig . suspense = config === undefined ? null : config ;
1528- try {
1529- setPending ( false ) ;
1530- callback ( ) ;
1531- } finally {
1532- setCurrentUpdateLanePriority ( previousLanePriority ) ;
1533- ReactCurrentBatchConfig . suspense = previousConfig ;
1534- }
1535- } ,
1536- ) ;
1525+ // If there's no SuspenseConfig set, we'll use the DefaultLanePriority for this transition.
1526+ setCurrentUpdateLanePriority ( DefaultLanePriority ) ;
1527+
1528+ runWithPriority (
1529+ priorityLevel > NormalPriority ? NormalPriority : priorityLevel ,
1530+ ( ) => {
1531+ const previousConfig = ReactCurrentBatchConfig . suspense ;
1532+ ReactCurrentBatchConfig . suspense = config === undefined ? null : config ;
1533+ try {
1534+ setPending ( false ) ;
1535+ callback ( ) ;
1536+ } finally {
1537+ if ( decoupleUpdatePriorityFromScheduler ) {
1538+ setCurrentUpdateLanePriority ( previousLanePriority ) ;
1539+ }
1540+ ReactCurrentBatchConfig . suspense = previousConfig ;
1541+ }
1542+ } ,
1543+ ) ;
1544+ } else {
1545+ runWithPriority (
1546+ priorityLevel < UserBlockingPriority
1547+ ? UserBlockingPriority
1548+ : priorityLevel ,
1549+ ( ) => {
1550+ setPending ( true ) ;
1551+ } ,
1552+ ) ;
1553+
1554+ runWithPriority (
1555+ priorityLevel > NormalPriority ? NormalPriority : priorityLevel ,
1556+ ( ) => {
1557+ const previousConfig = ReactCurrentBatchConfig . suspense ;
1558+ ReactCurrentBatchConfig . suspense = config === undefined ? null : config ;
1559+ try {
1560+ setPending ( false ) ;
1561+ callback ( ) ;
1562+ } finally {
1563+ ReactCurrentBatchConfig . suspense = previousConfig ;
1564+ }
1565+ } ,
1566+ ) ;
1567+ }
15371568}
15381569
15391570function mountTransition (
0 commit comments