Skip to content

Commit 164fa8d

Browse files
committed
Add feature flag to use microtasks in the React Native Fabric renderer
1 parent 41f0e9d commit 164fa8d

10 files changed

+26
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ const {
4848
unstable_getCurrentEventPriority: fabricGetCurrentEventPriority,
4949
} = nativeFabricUIManager;
5050

51-
import {diffInCommitPhase} from 'shared/ReactFeatureFlags';
51+
import {
52+
diffInCommitPhase,
53+
useMicrotasksForSchedulingInFabric,
54+
} from 'shared/ReactFeatureFlags';
5255

5356
const {get: getViewConfigForType} = ReactNativeViewConfigRegistry;
5457

@@ -122,7 +125,6 @@ export * from 'react-reconciler/src/ReactFiberConfigWithNoMutation';
122125
export * from 'react-reconciler/src/ReactFiberConfigWithNoHydration';
123126
export * from 'react-reconciler/src/ReactFiberConfigWithNoScopes';
124127
export * from 'react-reconciler/src/ReactFiberConfigWithNoTestSelectors';
125-
export * from 'react-reconciler/src/ReactFiberConfigWithNoMicrotasks';
126128
export * from 'react-reconciler/src/ReactFiberConfigWithNoResources';
127129
export * from 'react-reconciler/src/ReactFiberConfigWithNoSingletons';
128130

@@ -499,3 +501,10 @@ export function waitForCommitToBeReady(): null {
499501
}
500502

501503
export const NotPendingTransition: TransitionStatus = null;
504+
505+
// -------------------
506+
// Microtasks
507+
// -------------------
508+
export const supportsMicrotasks = useMicrotasksForSchedulingInFabric;
509+
export const scheduleMicrotask: any =
510+
typeof queueMicrotask === 'function' ? queueMicrotask : scheduleTimeout;

packages/shared/ReactFeatureFlags.js

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

126126
export const alwaysThrottleRetries = true;
127127

128+
export const useMicrotasksForSchedulingInFabric = false;
129+
128130
// -----------------------------------------------------------------------------
129131
// Chopping Block
130132
//

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
@@ -78,5 +78,7 @@ export const enableAsyncActions = false;
7878

7979
export const alwaysThrottleRetries = true;
8080

81+
export const useMicrotasksForSchedulingInFabric = false;
82+
8183
// Flow magic to verify the exports of this file match the original version.
8284
((((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
@@ -78,5 +78,7 @@ export const enableAsyncActions = false;
7878

7979
export const alwaysThrottleRetries = true;
8080

81+
export const useMicrotasksForSchedulingInFabric = false;
82+
8183
// Flow magic to verify the exports of this file match the original version.
8284
((((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
@@ -75,5 +75,7 @@ export const enableAsyncActions = false;
7575

7676
export const alwaysThrottleRetries = true;
7777

78+
export const useMicrotasksForSchedulingInFabric = false;
79+
7880
// Flow magic to verify the exports of this file match the original version.
7981
((((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
@@ -78,5 +78,7 @@ export const enableAsyncActions = false;
7878

7979
export const alwaysThrottleRetries = true;
8080

81+
export const useMicrotasksForSchedulingInFabric = false;
82+
8183
// Flow magic to verify the exports of this file match the original version.
8284
((((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
@@ -109,5 +109,7 @@ export const enableFizzExternalRuntime = true;
109109

110110
export const forceConcurrentByDefaultForTesting = false;
111111

112+
export const useMicrotasksForSchedulingInFabric = false;
113+
112114
// Flow magic to verify the exports of this file match the original version.
113115
((((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)