Skip to content

Commit 223804d

Browse files
committed
Add feature flag to use microtasks in the React Native Fabric renderer
1 parent a6ed60a commit 223804d

10 files changed

+24
-1
lines changed

packages/react-native-renderer/src/ReactFiberConfigFabric.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ const {
4747
unstable_getCurrentEventPriority: fabricGetCurrentEventPriority,
4848
} = nativeFabricUIManager;
4949

50+
import {useMicrotasksForSchedulingInFabric} from 'shared/ReactFeatureFlags';
51+
5052
const {get: getViewConfigForType} = ReactNativeViewConfigRegistry;
5153

5254
// Counter for uniquely identifying views.
@@ -119,7 +121,6 @@ export * from 'react-reconciler/src/ReactFiberConfigWithNoMutation';
119121
export * from 'react-reconciler/src/ReactFiberConfigWithNoHydration';
120122
export * from 'react-reconciler/src/ReactFiberConfigWithNoScopes';
121123
export * from 'react-reconciler/src/ReactFiberConfigWithNoTestSelectors';
122-
export * from 'react-reconciler/src/ReactFiberConfigWithNoMicrotasks';
123124
export * from 'react-reconciler/src/ReactFiberConfigWithNoResources';
124125
export * from 'react-reconciler/src/ReactFiberConfigWithNoSingletons';
125126

@@ -470,3 +471,10 @@ export function waitForCommitToBeReady(): null {
470471
}
471472

472473
export const NotPendingTransition: TransitionStatus = null;
474+
475+
// -------------------
476+
// Microtasks
477+
// -------------------
478+
export const supportsMicrotasks = useMicrotasksForSchedulingInFabric;
479+
export const scheduleMicrotask: any =
480+
typeof queueMicrotask === 'function' ? queueMicrotask : scheduleTimeout;

packages/shared/ReactFeatureFlags.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ export const enableAsyncActions = __EXPERIMENTAL__;
122122

123123
export const alwaysThrottleRetries = true;
124124

125+
export const useMicrotasksForSchedulingInFabric = false;
126+
125127
// -----------------------------------------------------------------------------
126128
// Chopping Block
127129
//

packages/shared/forks/ReactFeatureFlags.native-fb-dynamic.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import typeof * as DynamicFlagsType from 'ReactNativeInternalFeatureFlags';
2323
export const enableUseRefAccessWarning = __VARIANT__;
2424
export const enableDeferRootSchedulingToMicrotask = __VARIANT__;
2525
export const alwaysThrottleRetries = __VARIANT__;
26+
export const useMicrotasksForSchedulingInFabric = __VARIANT__;
2627

2728
// Flow magic to verify the exports of this file match the original version.
2829
((((null: any): ExportsType): DynamicFlagsType): ExportsType);

packages/shared/forks/ReactFeatureFlags.native-fb.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const {
2121
enableUseRefAccessWarning,
2222
enableDeferRootSchedulingToMicrotask,
2323
alwaysThrottleRetries,
24+
useMicrotasksForSchedulingInFabric,
2425
} = dynamicFlags;
2526

2627
// The rest of the flags are static for better dead code elimination.

packages/shared/forks/ReactFeatureFlags.native-oss.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,7 @@ export const enableAsyncActions = false;
7777

7878
export const alwaysThrottleRetries = true;
7979

80+
export const useMicrotasksForSchedulingInFabric = false;
81+
8082
// Flow magic to verify the exports of this file match the original version.
8183
((((null: any): ExportsType): FeatureFlagsType): ExportsType);

packages/shared/forks/ReactFeatureFlags.test-renderer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,7 @@ export const enableAsyncActions = false;
7777

7878
export const alwaysThrottleRetries = true;
7979

80+
export const useMicrotasksForSchedulingInFabric = false;
81+
8082
// Flow magic to verify the exports of this file match the original version.
8183
((((null: any): ExportsType): FeatureFlagsType): ExportsType);

packages/shared/forks/ReactFeatureFlags.test-renderer.native.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,7 @@ export const enableAsyncActions = false;
7474

7575
export const alwaysThrottleRetries = true;
7676

77+
export const useMicrotasksForSchedulingInFabric = false;
78+
7779
// Flow magic to verify the exports of this file match the original version.
7880
((((null: any): ExportsType): FeatureFlagsType): ExportsType);

packages/shared/forks/ReactFeatureFlags.test-renderer.www.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,7 @@ export const enableAsyncActions = false;
7777

7878
export const alwaysThrottleRetries = true;
7979

80+
export const useMicrotasksForSchedulingInFabric = false;
81+
8082
// Flow magic to verify the exports of this file match the original version.
8183
((((null: any): ExportsType): FeatureFlagsType): ExportsType);

packages/shared/forks/ReactFeatureFlags.www.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,7 @@ export const enableFizzExternalRuntime = true;
108108

109109
export const forceConcurrentByDefaultForTesting = false;
110110

111+
export const useMicrotasksForSchedulingInFabric = false;
112+
111113
// Flow magic to verify the exports of this file match the original version.
112114
((((null: any): ExportsType): FeatureFlagsType): ExportsType);

scripts/flow/xplat.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ declare module 'ReactNativeInternalFeatureFlags' {
1111
declare export var enableUseRefAccessWarning: boolean;
1212
declare export var enableDeferRootSchedulingToMicrotask: boolean;
1313
declare export var alwaysThrottleRetries: boolean;
14+
declare export var useMicrotasksForSchedulingInFabric: boolean;
1415
}

0 commit comments

Comments
 (0)