From 3b739ec5525d21da9b7301d68030a60729619b5c Mon Sep 17 00:00:00 2001 From: Rick Hanlon Date: Mon, 8 Mar 2021 14:32:47 -0700 Subject: [PATCH 1/3] Land enableNativeEventPriorityInference --- .../ReactDOMNativeEventHeuristic-test.js | 5 - .../src/createReactNoop.js | 20 +--- .../src/ReactFiberWorkLoop.new.js | 13 +-- .../src/ReactFiberWorkLoop.old.js | 13 +-- .../ReactSchedulerIntegration-test.js | 106 ------------------ .../useMutableSourceHydration-test.js | 1 - packages/shared/ReactFeatureFlags.js | 2 - .../forks/ReactFeatureFlags.native-fb.js | 1 - .../forks/ReactFeatureFlags.native-oss.js | 1 - .../forks/ReactFeatureFlags.test-renderer.js | 1 - .../ReactFeatureFlags.test-renderer.native.js | 1 - .../ReactFeatureFlags.test-renderer.www.js | 1 - .../shared/forks/ReactFeatureFlags.testing.js | 1 - .../forks/ReactFeatureFlags.testing.www.js | 1 - .../forks/ReactFeatureFlags.www-dynamic.js | 1 - .../shared/forks/ReactFeatureFlags.www.js | 1 - 16 files changed, 10 insertions(+), 159 deletions(-) diff --git a/packages/react-dom/src/__tests__/ReactDOMNativeEventHeuristic-test.js b/packages/react-dom/src/__tests__/ReactDOMNativeEventHeuristic-test.js index 1a37b74f71bf8..7c87698b1a35b 100644 --- a/packages/react-dom/src/__tests__/ReactDOMNativeEventHeuristic-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMNativeEventHeuristic-test.js @@ -43,7 +43,6 @@ describe('ReactDOMNativeEventHeuristic-test', () => { } // @gate experimental - // @gate enableNativeEventPriorityInference it('ignores discrete events on a pending removed element', async () => { const disableButtonRef = React.createRef(); const submitButtonRef = React.createRef(); @@ -95,7 +94,6 @@ describe('ReactDOMNativeEventHeuristic-test', () => { }); // @gate experimental - // @gate enableNativeEventPriorityInference it('ignores discrete events on a pending removed event listener', async () => { const disableButtonRef = React.createRef(); const submitButtonRef = React.createRef(); @@ -165,7 +163,6 @@ describe('ReactDOMNativeEventHeuristic-test', () => { }); // @gate experimental - // @gate enableNativeEventPriorityInference it('uses the newest discrete events on a pending changed event listener', async () => { const enableButtonRef = React.createRef(); const submitButtonRef = React.createRef(); @@ -229,7 +226,6 @@ describe('ReactDOMNativeEventHeuristic-test', () => { }); // @gate experimental - // @gate enableNativeEventPriorityInference it('mouse over should be user-blocking but not discrete', async () => { const root = ReactDOM.unstable_createRoot(container); @@ -260,7 +256,6 @@ describe('ReactDOMNativeEventHeuristic-test', () => { }); // @gate experimental - // @gate enableNativeEventPriorityInference it('mouse enter should be user-blocking but not discrete', async () => { const root = ReactDOM.unstable_createRoot(container); diff --git a/packages/react-noop-renderer/src/createReactNoop.js b/packages/react-noop-renderer/src/createReactNoop.js index 1a7ccbd07fbc3..f7663b0593583 100644 --- a/packages/react-noop-renderer/src/createReactNoop.js +++ b/packages/react-noop-renderer/src/createReactNoop.js @@ -27,7 +27,6 @@ import { LegacyRoot, } from 'react-reconciler/src/ReactRootTags'; -import {enableNativeEventPriorityInference} from 'shared/ReactFeatureFlags'; import ReactSharedInternals from 'shared/ReactSharedInternals'; import enqueueTask from 'shared/enqueueTask'; const {IsSomeRendererActing} = ReactSharedInternals; @@ -934,19 +933,12 @@ function createReactNoop(reconciler: Function, useMutation: boolean) { discreteUpdates: NoopRenderer.discreteUpdates, idleUpdates(fn: () => T): T { - if (enableNativeEventPriorityInference) { - const prevEventPriority = currentEventPriority; - currentEventPriority = NoopRenderer.IdleEventPriority; - try { - fn(); - } finally { - currentEventPriority = prevEventPriority; - } - } else { - return Scheduler.unstable_runWithPriority( - Scheduler.unstable_IdlePriority, - fn, - ); + const prevEventPriority = currentEventPriority; + currentEventPriority = NoopRenderer.IdleEventPriority; + try { + fn(); + } finally { + currentEventPriority = prevEventPriority; } }, diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.new.js b/packages/react-reconciler/src/ReactFiberWorkLoop.new.js index 65dc3f59181fc..5b6d174316434 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.new.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.new.js @@ -32,7 +32,6 @@ import { disableSchedulerTimeoutInWorkLoop, enableStrictEffects, skipUnmountedBoundaries, - enableNativeEventPriorityInference, } from 'shared/ReactFeatureFlags'; import ReactSharedInternals from 'shared/ReactSharedInternals'; import invariant from 'shared/invariant'; @@ -168,7 +167,6 @@ import { markRootExpired, markDiscreteUpdatesExpired, markRootFinished, - schedulerPriorityToLanePriority, lanePriorityToSchedulerPriority, higherLanePriority, } from './ReactFiberLane.new'; @@ -456,15 +454,8 @@ export function requestUpdateLane(fiber: Fiber): Lane { const currentLanePriority = getCurrentUpdateLanePriority(); lane = findUpdateLane(currentLanePriority); } else { - if (enableNativeEventPriorityInference) { - const eventLanePriority = getCurrentEventPriority(); - lane = findUpdateLane(eventLanePriority); - } else { - const schedulerLanePriority = schedulerPriorityToLanePriority( - schedulerPriority, - ); - lane = findUpdateLane(schedulerLanePriority); - } + const eventLanePriority = getCurrentEventPriority(); + lane = findUpdateLane(eventLanePriority); } return lane; diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.old.js b/packages/react-reconciler/src/ReactFiberWorkLoop.old.js index a265ec896b774..a41d723dfe1ab 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.old.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.old.js @@ -32,7 +32,6 @@ import { disableSchedulerTimeoutInWorkLoop, enableStrictEffects, skipUnmountedBoundaries, - enableNativeEventPriorityInference, } from 'shared/ReactFeatureFlags'; import ReactSharedInternals from 'shared/ReactSharedInternals'; import invariant from 'shared/invariant'; @@ -168,7 +167,6 @@ import { markRootExpired, markDiscreteUpdatesExpired, markRootFinished, - schedulerPriorityToLanePriority, lanePriorityToSchedulerPriority, higherLanePriority, } from './ReactFiberLane.old'; @@ -456,15 +454,8 @@ export function requestUpdateLane(fiber: Fiber): Lane { const currentLanePriority = getCurrentUpdateLanePriority(); lane = findUpdateLane(currentLanePriority); } else { - if (enableNativeEventPriorityInference) { - const eventLanePriority = getCurrentEventPriority(); - lane = findUpdateLane(eventLanePriority); - } else { - const schedulerLanePriority = schedulerPriorityToLanePriority( - schedulerPriority, - ); - lane = findUpdateLane(schedulerLanePriority); - } + const eventLanePriority = getCurrentEventPriority(); + lane = findUpdateLane(eventLanePriority); } return lane; diff --git a/packages/react-reconciler/src/__tests__/ReactSchedulerIntegration-test.js b/packages/react-reconciler/src/__tests__/ReactSchedulerIntegration-test.js index bc05d1ab13d0b..c0ab53a40dc08 100644 --- a/packages/react-reconciler/src/__tests__/ReactSchedulerIntegration-test.js +++ b/packages/react-reconciler/src/__tests__/ReactSchedulerIntegration-test.js @@ -13,10 +13,7 @@ let React; let ReactNoop; let Scheduler; -let ImmediatePriority; -let UserBlockingPriority; let NormalPriority; -let LowPriority; let IdlePriority; let runWithPriority; let startTransition; @@ -28,33 +25,12 @@ describe('ReactSchedulerIntegration', () => { React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); - ImmediatePriority = Scheduler.unstable_ImmediatePriority; - UserBlockingPriority = Scheduler.unstable_UserBlockingPriority; NormalPriority = Scheduler.unstable_NormalPriority; - LowPriority = Scheduler.unstable_LowPriority; IdlePriority = Scheduler.unstable_IdlePriority; runWithPriority = Scheduler.unstable_runWithPriority; startTransition = React.unstable_startTransition; }); - function getCurrentPriorityAsString() { - const priorityLevel = Scheduler.unstable_getCurrentPriorityLevel(); - switch (priorityLevel) { - case ImmediatePriority: - return 'Immediate'; - case UserBlockingPriority: - return 'UserBlocking'; - case NormalPriority: - return 'Normal'; - case LowPriority: - return 'Low'; - case IdlePriority: - return 'Idle'; - default: - throw Error('Unknown priority level: ' + priorityLevel); - } - } - // Note: This is based on a similar component we use in www. We can delete // once the extra div wrapper is no longer necessary. function LegacyHiddenDiv({children, mode}) { @@ -68,66 +44,6 @@ describe('ReactSchedulerIntegration', () => { ); } - // TODO: Figure out what to do with these tests. I don't think most of them - // make sense once we decouple Scheduler from React. Perhaps need similar - // tests for React DOM. - // @gate !enableNativeEventPriorityInference - it('has correct priority during rendering', () => { - function ReadPriority() { - Scheduler.unstable_yieldValue( - 'Priority: ' + getCurrentPriorityAsString(), - ); - return null; - } - ReactNoop.render(); - expect(Scheduler).toFlushAndYield(['Priority: Normal']); - - runWithPriority(UserBlockingPriority, () => { - ReactNoop.render(); - }); - expect(Scheduler).toFlushAndYield(['Priority: UserBlocking']); - - runWithPriority(IdlePriority, () => { - ReactNoop.render(); - }); - expect(Scheduler).toFlushAndYield(['Priority: Idle']); - }); - - // TODO: Figure out what to do with these tests. I don't think most of them - // make sense once we decouple Scheduler from React. Perhaps need similar - // tests for React DOM. - // @gate !enableNativeEventPriorityInference - it('has correct priority when continuing a render after yielding', () => { - function ReadPriority() { - Scheduler.unstable_yieldValue( - 'Priority: ' + getCurrentPriorityAsString(), - ); - return null; - } - - runWithPriority(UserBlockingPriority, () => { - ReactNoop.render( - <> - - - - , - ); - }); - - // Render part of the tree - expect(Scheduler).toFlushAndYieldThrough(['Priority: UserBlocking']); - - // Priority is set back to normal when yielding - expect(getCurrentPriorityAsString()).toEqual('Normal'); - - // Priority is restored to user-blocking when continuing - expect(Scheduler).toFlushAndYield([ - 'Priority: UserBlocking', - 'Priority: UserBlocking', - ]); - }); - it('passive effects are called before Normal-pri scheduled in layout effects', async () => { const {useEffect, useLayoutEffect} = React; function Effects({step}) { @@ -172,28 +88,6 @@ describe('ReactSchedulerIntegration', () => { ]); }); - // TODO: Figure out what to do with these tests. I don't think most of them - // make sense once we decouple Scheduler from React. Perhaps need similar - // tests for React DOM. - // @gate !enableNativeEventPriorityInference - it('after completing a level of work, infers priority of the next batch based on its expiration time', () => { - function App({label}) { - Scheduler.unstable_yieldValue( - `${label} [${getCurrentPriorityAsString()}]`, - ); - return label; - } - - // Schedule two separate updates at different priorities - runWithPriority(UserBlockingPriority, () => { - ReactNoop.render(); - }); - ReactNoop.render(); - - // The second update should run at normal priority - expect(Scheduler).toFlushAndYield(['A [UserBlocking]', 'B [Normal]']); - }); - it('requests a paint after committing', () => { const scheduleCallback = Scheduler.unstable_scheduleCallback; diff --git a/packages/react-reconciler/src/__tests__/useMutableSourceHydration-test.js b/packages/react-reconciler/src/__tests__/useMutableSourceHydration-test.js index 6afa7588bbfb0..c322a0a48ed4c 100644 --- a/packages/react-reconciler/src/__tests__/useMutableSourceHydration-test.js +++ b/packages/react-reconciler/src/__tests__/useMutableSourceHydration-test.js @@ -341,7 +341,6 @@ describe('useMutableSourceHydration', () => { }); // @gate experimental - // @gate enableNativeEventPriorityInference it('should detect a tear during a higher priority interruption', () => { const source = createSource('one'); const mutableSource = createMutableSource(source, param => param.version); diff --git a/packages/shared/ReactFeatureFlags.js b/packages/shared/ReactFeatureFlags.js index 4adc7ac9b4dd5..5029a6f4900bf 100644 --- a/packages/shared/ReactFeatureFlags.js +++ b/packages/shared/ReactFeatureFlags.js @@ -152,6 +152,4 @@ export const disableSchedulerTimeoutInWorkLoop = false; export const enableSyncMicroTasks = false; -export const enableNativeEventPriorityInference = false; - export const enableLazyContextPropagation = false; diff --git a/packages/shared/forks/ReactFeatureFlags.native-fb.js b/packages/shared/forks/ReactFeatureFlags.native-fb.js index 6c891df1b3ea9..b6a8016ec8b77 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-fb.js +++ b/packages/shared/forks/ReactFeatureFlags.native-fb.js @@ -58,7 +58,6 @@ export const enableUseRefAccessWarning = false; export const enableRecursiveCommitTraversal = false; export const disableSchedulerTimeoutInWorkLoop = false; export const enableSyncMicroTasks = false; -export const enableNativeEventPriorityInference = false; export const enableLazyContextPropagation = false; // Flow magic to verify the exports of this file match the original version. diff --git a/packages/shared/forks/ReactFeatureFlags.native-oss.js b/packages/shared/forks/ReactFeatureFlags.native-oss.js index 4e12e63a4fa09..cb8721af25fe9 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-oss.js +++ b/packages/shared/forks/ReactFeatureFlags.native-oss.js @@ -57,7 +57,6 @@ export const enableUseRefAccessWarning = false; export const enableRecursiveCommitTraversal = false; export const disableSchedulerTimeoutInWorkLoop = false; export const enableSyncMicroTasks = false; -export const enableNativeEventPriorityInference = false; export const enableLazyContextPropagation = false; // Flow magic to verify the exports of this file match the original version. diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.js index 27dd0cdc9bda5..b504491d98de2 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.js @@ -57,7 +57,6 @@ export const enableUseRefAccessWarning = false; export const enableRecursiveCommitTraversal = false; export const disableSchedulerTimeoutInWorkLoop = false; export const enableSyncMicroTasks = false; -export const enableNativeEventPriorityInference = false; export const enableLazyContextPropagation = false; // Flow magic to verify the exports of this file match the original version. diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js index 8d3f3a92ea231..ddab49284e437 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js @@ -57,7 +57,6 @@ export const enableUseRefAccessWarning = false; export const enableRecursiveCommitTraversal = false; export const disableSchedulerTimeoutInWorkLoop = false; export const enableSyncMicroTasks = false; -export const enableNativeEventPriorityInference = false; export const enableLazyContextPropagation = false; // Flow magic to verify the exports of this file match the original version. diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js index 5d14b1de5fc54..7098bfed2aa5b 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js @@ -57,7 +57,6 @@ export const enableUseRefAccessWarning = false; export const enableRecursiveCommitTraversal = false; export const disableSchedulerTimeoutInWorkLoop = false; export const enableSyncMicroTasks = false; -export const enableNativeEventPriorityInference = false; export const enableLazyContextPropagation = false; // Flow magic to verify the exports of this file match the original version. diff --git a/packages/shared/forks/ReactFeatureFlags.testing.js b/packages/shared/forks/ReactFeatureFlags.testing.js index 12fcc75be187c..a321f5ea12f92 100644 --- a/packages/shared/forks/ReactFeatureFlags.testing.js +++ b/packages/shared/forks/ReactFeatureFlags.testing.js @@ -57,7 +57,6 @@ export const enableUseRefAccessWarning = false; export const enableRecursiveCommitTraversal = false; export const disableSchedulerTimeoutInWorkLoop = false; export const enableSyncMicroTasks = false; -export const enableNativeEventPriorityInference = false; export const enableLazyContextPropagation = false; // Flow magic to verify the exports of this file match the original version. diff --git a/packages/shared/forks/ReactFeatureFlags.testing.www.js b/packages/shared/forks/ReactFeatureFlags.testing.www.js index c89caeffcf06f..bb6a952355657 100644 --- a/packages/shared/forks/ReactFeatureFlags.testing.www.js +++ b/packages/shared/forks/ReactFeatureFlags.testing.www.js @@ -57,7 +57,6 @@ export const enableUseRefAccessWarning = false; export const enableRecursiveCommitTraversal = false; export const disableSchedulerTimeoutInWorkLoop = false; export const enableSyncMicroTasks = false; -export const enableNativeEventPriorityInference = false; export const enableLazyContextPropagation = false; // Flow magic to verify the exports of this file match the original version. diff --git a/packages/shared/forks/ReactFeatureFlags.www-dynamic.js b/packages/shared/forks/ReactFeatureFlags.www-dynamic.js index 46dc190a61271..df98012634970 100644 --- a/packages/shared/forks/ReactFeatureFlags.www-dynamic.js +++ b/packages/shared/forks/ReactFeatureFlags.www-dynamic.js @@ -56,5 +56,4 @@ export const enableUseRefAccessWarning = __VARIANT__; export const enableProfilerNestedUpdateScheduledHook = __VARIANT__; export const disableSchedulerTimeoutInWorkLoop = __VARIANT__; export const enableSyncMicroTasks = __VARIANT__; -export const enableNativeEventPriorityInference = __VARIANT__; export const enableLazyContextPropagation = __VARIANT__; diff --git a/packages/shared/forks/ReactFeatureFlags.www.js b/packages/shared/forks/ReactFeatureFlags.www.js index 35bbe2cb1fbec..893c2699b0d07 100644 --- a/packages/shared/forks/ReactFeatureFlags.www.js +++ b/packages/shared/forks/ReactFeatureFlags.www.js @@ -32,7 +32,6 @@ export const { disableNativeComponentFrames, disableSchedulerTimeoutInWorkLoop, enableSyncMicroTasks, - enableNativeEventPriorityInference, enableLazyContextPropagation, } = dynamicFeatureFlags; From 7609723797431410539510eb4c2679af18346a5b Mon Sep 17 00:00:00 2001 From: Rick Hanlon Date: Mon, 8 Mar 2021 15:03:41 -0700 Subject: [PATCH 2/3] Move schedulerPriorityToLanePriority --- .../src/events/ReactDOMEventListener.js | 42 +++++++++++++++---- .../src/ReactFiberLane.new.js | 20 --------- .../src/ReactFiberLane.old.js | 20 --------- 3 files changed, 35 insertions(+), 47 deletions(-) diff --git a/packages/react-dom/src/events/ReactDOMEventListener.js b/packages/react-dom/src/events/ReactDOMEventListener.js index 28dc3a8c713c7..8a9bda86050ca 100644 --- a/packages/react-dom/src/events/ReactDOMEventListener.js +++ b/packages/react-dom/src/events/ReactDOMEventListener.js @@ -8,7 +8,10 @@ */ import type {AnyNativeEvent} from '../events/PluginModuleType'; -import type {FiberRoot} from 'react-reconciler/src/ReactInternalTypes'; +import type { + FiberRoot, + ReactPriorityLevel, +} from 'react-reconciler/src/ReactInternalTypes'; import type {Container, SuspenseInstance} from '../client/ReactDOMHostConfig'; import type {DOMEventName} from '../events/DOMEventNames'; @@ -50,7 +53,6 @@ import { DefaultLanePriority as DefaultLanePriority_old, getCurrentUpdateLanePriority as getCurrentUpdateLanePriority_old, setCurrentUpdateLanePriority as setCurrentUpdateLanePriority_old, - schedulerPriorityToLanePriority as schedulerPriorityToLanePriority_old, } from 'react-reconciler/src/ReactFiberLane.old'; import { InputDiscreteLanePriority as InputDiscreteLanePriority_new, @@ -58,10 +60,20 @@ import { DefaultLanePriority as DefaultLanePriority_new, getCurrentUpdateLanePriority as getCurrentUpdateLanePriority_new, setCurrentUpdateLanePriority as setCurrentUpdateLanePriority_new, - schedulerPriorityToLanePriority as schedulerPriorityToLanePriority_new, + SyncLanePriority, + IdleLanePriority, + NoLanePriority, } from 'react-reconciler/src/ReactFiberLane.new'; import {getCurrentPriorityLevel as getCurrentPriorityLevel_old} from 'react-reconciler/src/SchedulerWithReactIntegration.old'; -import {getCurrentPriorityLevel as getCurrentPriorityLevel_new} from 'react-reconciler/src/SchedulerWithReactIntegration.new'; +import { + getCurrentPriorityLevel as getCurrentPriorityLevel_new, + IdlePriority as IdleSchedulerPriority, + ImmediatePriority as ImmediateSchedulerPriority, + LowPriority as LowSchedulerPriority, + NormalPriority as NormalSchedulerPriority, + UserBlockingPriority as UserBlockingSchedulerPriority, +} from 'react-reconciler/src/SchedulerWithReactIntegration.new'; +import type {LanePriority} from 'react-reconciler/src/ReactFiberLane.new'; const InputDiscreteLanePriority = enableNewReconciler ? InputDiscreteLanePriority_new @@ -78,13 +90,29 @@ const getCurrentUpdateLanePriority = enableNewReconciler const setCurrentUpdateLanePriority = enableNewReconciler ? setCurrentUpdateLanePriority_new : setCurrentUpdateLanePriority_old; -const schedulerPriorityToLanePriority = enableNewReconciler - ? schedulerPriorityToLanePriority_new - : schedulerPriorityToLanePriority_old; const getCurrentPriorityLevel = enableNewReconciler ? getCurrentPriorityLevel_new : getCurrentPriorityLevel_old; +function schedulerPriorityToLanePriority( + schedulerPriorityLevel: ReactPriorityLevel, +): LanePriority { + switch (schedulerPriorityLevel) { + case ImmediateSchedulerPriority: + return SyncLanePriority; + case UserBlockingSchedulerPriority: + return InputContinuousLanePriority; + case NormalSchedulerPriority: + case LowSchedulerPriority: + // TODO: Handle LowSchedulerPriority, somehow. Maybe the same lane as hydration. + return DefaultLanePriority; + case IdleSchedulerPriority: + return IdleLanePriority; + default: + return NoLanePriority; + } +} + // TODO: can we stop exporting these? export let _enabled = true; diff --git a/packages/react-reconciler/src/ReactFiberLane.new.js b/packages/react-reconciler/src/ReactFiberLane.new.js index 7e577abb228e2..ef74b355ebfad 100644 --- a/packages/react-reconciler/src/ReactFiberLane.new.js +++ b/packages/react-reconciler/src/ReactFiberLane.new.js @@ -42,7 +42,6 @@ import { ImmediatePriority as ImmediateSchedulerPriority, UserBlockingPriority as UserBlockingSchedulerPriority, NormalPriority as NormalSchedulerPriority, - LowPriority as LowSchedulerPriority, IdlePriority as IdleSchedulerPriority, NoPriority as NoSchedulerPriority, } from './SchedulerWithReactIntegration.new'; @@ -275,25 +274,6 @@ function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes { } } -export function schedulerPriorityToLanePriority( - schedulerPriorityLevel: ReactPriorityLevel, -): LanePriority { - switch (schedulerPriorityLevel) { - case ImmediateSchedulerPriority: - return SyncLanePriority; - case UserBlockingSchedulerPriority: - return InputContinuousLanePriority; - case NormalSchedulerPriority: - case LowSchedulerPriority: - // TODO: Handle LowSchedulerPriority, somehow. Maybe the same lane as hydration. - return DefaultLanePriority; - case IdleSchedulerPriority: - return IdleLanePriority; - default: - return NoLanePriority; - } -} - export function lanePriorityToSchedulerPriority( lanePriority: LanePriority, ): ReactPriorityLevel { diff --git a/packages/react-reconciler/src/ReactFiberLane.old.js b/packages/react-reconciler/src/ReactFiberLane.old.js index af73a5e565871..4e2ce8942f08a 100644 --- a/packages/react-reconciler/src/ReactFiberLane.old.js +++ b/packages/react-reconciler/src/ReactFiberLane.old.js @@ -42,7 +42,6 @@ import { ImmediatePriority as ImmediateSchedulerPriority, UserBlockingPriority as UserBlockingSchedulerPriority, NormalPriority as NormalSchedulerPriority, - LowPriority as LowSchedulerPriority, IdlePriority as IdleSchedulerPriority, NoPriority as NoSchedulerPriority, } from './SchedulerWithReactIntegration.old'; @@ -275,25 +274,6 @@ function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes { } } -export function schedulerPriorityToLanePriority( - schedulerPriorityLevel: ReactPriorityLevel, -): LanePriority { - switch (schedulerPriorityLevel) { - case ImmediateSchedulerPriority: - return SyncLanePriority; - case UserBlockingSchedulerPriority: - return InputContinuousLanePriority; - case NormalSchedulerPriority: - case LowSchedulerPriority: - // TODO: Handle LowSchedulerPriority, somehow. Maybe the same lane as hydration. - return DefaultLanePriority; - case IdleSchedulerPriority: - return IdleLanePriority; - default: - return NoLanePriority; - } -} - export function lanePriorityToSchedulerPriority( lanePriority: LanePriority, ): ReactPriorityLevel { From 2038186888bff05cdf8ab1c43a9c9f5dc0c3ca5b Mon Sep 17 00:00:00 2001 From: Rick Hanlon Date: Mon, 8 Mar 2021 15:16:57 -0700 Subject: [PATCH 3/3] Remove obsolete comment --- packages/react-dom/src/events/ReactDOMEventListener.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/react-dom/src/events/ReactDOMEventListener.js b/packages/react-dom/src/events/ReactDOMEventListener.js index 8a9bda86050ca..0869bebe330bb 100644 --- a/packages/react-dom/src/events/ReactDOMEventListener.js +++ b/packages/react-dom/src/events/ReactDOMEventListener.js @@ -438,8 +438,6 @@ export function getEventPriority(domEventName: DOMEventName): * { // Eventually this mechanism will be replaced by a check // of the current priority on the native scheduler. const schedulerPriority = getCurrentPriorityLevel(); - // TODO: Inline schedulerPriorityToLanePriority into this file - // when we delete the enableNativeEventPriorityInference flag. return schedulerPriorityToLanePriority(schedulerPriority); } default: