@samitouri / QOS-React-2 / commits / 5e9b48778c

[RN] Map Fabric priorities to reconciler priorities correctly (#32847)

## Summary This fixes how we map priorities between Fabric and the React reconciler. At the moment, we're only considering default and discrete priorities, when there's a larger range of priorities available. In Fabric, we'll test supporting additional priorities soon. For that test to do something useful, we need the new priorities to be mapped to reconciler priorities correctly, which is what this change is done. > [!IMPORTANT] > At the moment, this is a no-op because Fabric is only reporting default and discrete event priorities. ## How did you test this change? Will test e2e on React Native on top of https://github.com/facebook/react-native/pull/50627 The changes are gated in React Native, so we'll use that feature flag to test this.

Rubén Norte committed Apr 10, 2025 at 17:35 UTC 5e9b48778c83dd8b2c63966db3e23abefebe910c
2 files changed +10
packages/react-native-renderer/src/ReactFiberConfigFabric.js
+8
@@ -18,6 +18,8 @@ import {
18 NoEventPriority,
19 DefaultEventPriority,
20 DiscreteEventPriority,
21 + ContinuousEventPriority,
22 + IdleEventPriority,
23 type EventPriority,
24 } from 'react-reconciler/src/ReactEventPriorities';
25 import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
@@ -46,6 +48,8 @@ const {
48 registerEventHandler,
49 unstable_DefaultEventPriority: FabricDefaultPriority,
50 unstable_DiscreteEventPriority: FabricDiscretePriority,
51 + unstable_ContinuousEventPriority: FabricContinuousPriority,
52 + unstable_IdleEventPriority: FabricIdlePriority,
53 unstable_getCurrentEventPriority: fabricGetCurrentEventPriority,
54 } = nativeFabricUIManager;
55
@@ -397,6 +401,10 @@ export function resolveUpdatePriority(): EventPriority {
401 switch (currentEventPriority) {
402 case FabricDiscretePriority:
403 return DiscreteEventPriority;
404 + case FabricContinuousPriority:
405 + return ContinuousEventPriority;
406 + case FabricIdlePriority:
407 + return IdleEventPriority;
408 case FabricDefaultPriority:
409 default:
410 return DefaultEventPriority;
scripts/flow/react-native-host-hooks.js
+2
@@ -277,6 +277,8 @@ declare const nativeFabricUIManager: {
277 ) => void,
278 unstable_DefaultEventPriority: number,
279 unstable_DiscreteEventPriority: number,
280 + unstable_ContinuousEventPriority: number,
281 + unstable_IdleEventPriority: number,
282 unstable_getCurrentEventPriority: () => number,
283 ...
284 };