Skip to content

Commit

Permalink
[RN] Use microtasks when using bridgeless mode in React Native Fabric…
Browse files Browse the repository at this point in the history
… renderer (OSS version)
  • Loading branch information
rubennorte committed Mar 11, 2024
1 parent dfaed55 commit 90c9589
Show file tree
Hide file tree
Showing 13 changed files with 11 additions and 15 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ module.exports = {
files: ['packages/react-native-renderer/**/*.js'],
globals: {
nativeFabricUIManager: 'readonly',
RN$enableMicrotasksInReact: 'readonly',
},
},
{
Expand Down
11 changes: 6 additions & 5 deletions packages/react-native-renderer/src/ReactFiberConfigFabric.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ const {
unstable_getCurrentEventPriority: fabricGetCurrentEventPriority,
} = nativeFabricUIManager;

import {
useMicrotasksForSchedulingInFabric,
passChildrenWhenCloningPersistedNodes,
} from 'shared/ReactFeatureFlags';
import {passChildrenWhenCloningPersistedNodes} from 'shared/ReactFeatureFlags';

const {get: getViewConfigForType} = ReactNativeViewConfigRegistry;

Expand Down Expand Up @@ -507,6 +504,10 @@ export const NotPendingTransition: TransitionStatus = null;
// -------------------
// Microtasks
// -------------------
export const supportsMicrotasks = useMicrotasksForSchedulingInFabric;

export const supportsMicrotasks: boolean =
typeof RN$enableMicrotasksInReact !== 'undefined' &&
!!RN$enableMicrotasksInReact;

export const scheduleMicrotask: any =
typeof queueMicrotask === 'function' ? queueMicrotask : scheduleTimeout;
2 changes: 0 additions & 2 deletions packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ export const enableFizzExternalRuntime = true;

export const alwaysThrottleRetries = true;

export const useMicrotasksForSchedulingInFabric = false;

export const passChildrenWhenCloningPersistedNodes = false;

export const enableUseDeferredValueInitialArg = __EXPERIMENTAL__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export const enableRenderableContext = __VARIANT__;
export const enableUnifiedSyncLane = __VARIANT__;
export const enableUseRefAccessWarning = __VARIANT__;
export const passChildrenWhenCloningPersistedNodes = __VARIANT__;
export const useMicrotasksForSchedulingInFabric = __VARIANT__;
export const useModernStrictMode = __VARIANT__;

// Flow magic to verify the exports of this file match the original version.
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.native-fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export const {
enableUnifiedSyncLane,
enableUseRefAccessWarning,
passChildrenWhenCloningPersistedNodes,
useMicrotasksForSchedulingInFabric,
useModernStrictMode,
} = dynamicFlags;

Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.native-oss.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ export const enableAsyncActions = false;

export const alwaysThrottleRetries = false;

export const useMicrotasksForSchedulingInFabric = false;
export const passChildrenWhenCloningPersistedNodes = false;
export const enableUseDeferredValueInitialArg = __EXPERIMENTAL__;
export const disableClientCache = true;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.test-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ export const enableAsyncActions = true;

export const alwaysThrottleRetries = true;

export const useMicrotasksForSchedulingInFabric = false;
export const passChildrenWhenCloningPersistedNodes = false;
export const enableUseDeferredValueInitialArg = __EXPERIMENTAL__;
export const disableClientCache = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export const enableAsyncActions = true;

export const alwaysThrottleRetries = true;

export const useMicrotasksForSchedulingInFabric = false;
export const passChildrenWhenCloningPersistedNodes = false;
export const enableUseDeferredValueInitialArg = __EXPERIMENTAL__;
export const disableClientCache = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ export const enableAsyncActions = true;

export const alwaysThrottleRetries = true;

export const useMicrotasksForSchedulingInFabric = false;
export const passChildrenWhenCloningPersistedNodes = false;
export const enableUseDeferredValueInitialArg = true;
export const disableClientCache = true;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ export const enableFizzExternalRuntime = true;

export const forceConcurrentByDefaultForTesting = false;

export const useMicrotasksForSchedulingInFabric = false;
export const passChildrenWhenCloningPersistedNodes = false;

export const enableAsyncDebugInfo = false;
Expand Down
2 changes: 2 additions & 0 deletions scripts/flow/react-native-host-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ declare module 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface'
declare module 'react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore' {
}

declare const RN$enableMicrotasksInReact: boolean;

// This is needed for a short term solution.
// See https://github.com/facebook/react/pull/15490 for more info
declare var nativeFabricUIManager: {
Expand Down
1 change: 0 additions & 1 deletion scripts/flow/xplat.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ declare module 'ReactNativeInternalFeatureFlags' {
declare export var enableUnifiedSyncLane: boolean;
declare export var enableUseRefAccessWarning: boolean;
declare export var passChildrenWhenCloningPersistedNodes: boolean;
declare export var useMicrotasksForSchedulingInFabric: boolean;
declare export var useModernStrictMode: boolean;
}
2 changes: 2 additions & 0 deletions scripts/rollup/validate/eslintrc.rn.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ module.exports = {
// Fabric. See https://github.com/facebook/react/pull/15490
// for more information
nativeFabricUIManager: 'readonly',
// RN flag to enable microtasks
RN$enableMicrotasksInReact: 'readonly',
// Trusted Types
trustedTypes: 'readonly',
// RN supports this
Expand Down

0 comments on commit 90c9589

Please sign in to comment.