diff --git a/packages/react-native-renderer/src/ReactFiberConfigFabric.js b/packages/react-native-renderer/src/ReactFiberConfigFabric.js index d1d669ee829d4..ff487b4d0360e 100644 --- a/packages/react-native-renderer/src/ReactFiberConfigFabric.js +++ b/packages/react-native-renderer/src/ReactFiberConfigFabric.js @@ -48,7 +48,10 @@ const { unstable_getCurrentEventPriority: fabricGetCurrentEventPriority, } = nativeFabricUIManager; -import {diffInCommitPhase} from 'shared/ReactFeatureFlags'; +import { + diffInCommitPhase, + useMicrotasksForSchedulingInFabric, +} from 'shared/ReactFeatureFlags'; const {get: getViewConfigForType} = ReactNativeViewConfigRegistry; @@ -122,7 +125,6 @@ export * from 'react-reconciler/src/ReactFiberConfigWithNoMutation'; export * from 'react-reconciler/src/ReactFiberConfigWithNoHydration'; export * from 'react-reconciler/src/ReactFiberConfigWithNoScopes'; export * from 'react-reconciler/src/ReactFiberConfigWithNoTestSelectors'; -export * from 'react-reconciler/src/ReactFiberConfigWithNoMicrotasks'; export * from 'react-reconciler/src/ReactFiberConfigWithNoResources'; export * from 'react-reconciler/src/ReactFiberConfigWithNoSingletons'; @@ -499,3 +501,10 @@ export function waitForCommitToBeReady(): null { } export const NotPendingTransition: TransitionStatus = null; + +// ------------------- +// Microtasks +// ------------------- +export const supportsMicrotasks = useMicrotasksForSchedulingInFabric; +export const scheduleMicrotask: any = + typeof queueMicrotask === 'function' ? queueMicrotask : scheduleTimeout; diff --git a/packages/shared/ReactFeatureFlags.js b/packages/shared/ReactFeatureFlags.js index 44dc2ce07c064..4cfe2d2f34dfe 100644 --- a/packages/shared/ReactFeatureFlags.js +++ b/packages/shared/ReactFeatureFlags.js @@ -125,6 +125,8 @@ export const enableAsyncActions = __EXPERIMENTAL__; export const alwaysThrottleRetries = true; +export const useMicrotasksForSchedulingInFabric = false; + // ----------------------------------------------------------------------------- // Chopping Block // diff --git a/packages/shared/forks/ReactFeatureFlags.native-fb-dynamic.js b/packages/shared/forks/ReactFeatureFlags.native-fb-dynamic.js index 92449bcd6a8ca..7ef1ef3013f17 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-fb-dynamic.js +++ b/packages/shared/forks/ReactFeatureFlags.native-fb-dynamic.js @@ -23,6 +23,7 @@ import typeof * as DynamicFlagsType from 'ReactNativeInternalFeatureFlags'; export const enableUseRefAccessWarning = __VARIANT__; export const enableDeferRootSchedulingToMicrotask = __VARIANT__; export const alwaysThrottleRetries = __VARIANT__; +export const useMicrotasksForSchedulingInFabric = __VARIANT__; // Flow magic to verify the exports of this file match the original version. ((((null: any): ExportsType): DynamicFlagsType): ExportsType); diff --git a/packages/shared/forks/ReactFeatureFlags.native-fb.js b/packages/shared/forks/ReactFeatureFlags.native-fb.js index ec7d4e6cf5831..4a94ba6607948 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-fb.js +++ b/packages/shared/forks/ReactFeatureFlags.native-fb.js @@ -21,6 +21,7 @@ export const { enableUseRefAccessWarning, enableDeferRootSchedulingToMicrotask, alwaysThrottleRetries, + useMicrotasksForSchedulingInFabric, } = dynamicFlags; // The rest of the flags are static for better dead code elimination. diff --git a/packages/shared/forks/ReactFeatureFlags.native-oss.js b/packages/shared/forks/ReactFeatureFlags.native-oss.js index c70b20b57fda1..cd2e7949551e4 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-oss.js +++ b/packages/shared/forks/ReactFeatureFlags.native-oss.js @@ -78,5 +78,7 @@ export const enableAsyncActions = false; export const alwaysThrottleRetries = true; +export const useMicrotasksForSchedulingInFabric = false; + // Flow magic to verify the exports of this file match the original version. ((((null: any): ExportsType): FeatureFlagsType): ExportsType); diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.js index 86f2d6ff6d3b4..eb35139349078 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.js @@ -78,5 +78,7 @@ export const enableAsyncActions = false; export const alwaysThrottleRetries = true; +export const useMicrotasksForSchedulingInFabric = false; + // Flow magic to verify the exports of this file match the original version. ((((null: any): ExportsType): FeatureFlagsType): ExportsType); diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js index 50717886640ea..e4bbb7a319dfa 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js @@ -75,5 +75,7 @@ export const enableAsyncActions = false; export const alwaysThrottleRetries = true; +export const useMicrotasksForSchedulingInFabric = false; + // Flow magic to verify the exports of this file match the original version. ((((null: any): ExportsType): FeatureFlagsType): ExportsType); diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js index 7ac6b230bcaf8..0144f2ea2a52e 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js @@ -78,5 +78,7 @@ export const enableAsyncActions = false; export const alwaysThrottleRetries = true; +export const useMicrotasksForSchedulingInFabric = false; + // Flow magic to verify the exports of this file match the original version. ((((null: any): ExportsType): FeatureFlagsType): ExportsType); diff --git a/packages/shared/forks/ReactFeatureFlags.www.js b/packages/shared/forks/ReactFeatureFlags.www.js index 466e0a5aa18e1..92e50657a45d9 100644 --- a/packages/shared/forks/ReactFeatureFlags.www.js +++ b/packages/shared/forks/ReactFeatureFlags.www.js @@ -109,5 +109,7 @@ export const enableFizzExternalRuntime = true; export const forceConcurrentByDefaultForTesting = false; +export const useMicrotasksForSchedulingInFabric = false; + // Flow magic to verify the exports of this file match the original version. ((((null: any): ExportsType): FeatureFlagsType): ExportsType); diff --git a/scripts/flow/xplat.js b/scripts/flow/xplat.js index 37d1deee75275..889d76ea93371 100644 --- a/scripts/flow/xplat.js +++ b/scripts/flow/xplat.js @@ -11,4 +11,5 @@ declare module 'ReactNativeInternalFeatureFlags' { declare export var enableUseRefAccessWarning: boolean; declare export var enableDeferRootSchedulingToMicrotask: boolean; declare export var alwaysThrottleRetries: boolean; + declare export var useMicrotasksForSchedulingInFabric: boolean; }