From 52e7313f14b1fa5c0c2b43b1a9309646b41e0bed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Thu, 29 Feb 2024 14:16:16 +0000 Subject: [PATCH] [RN] Use microtasks when using bridgeless mode in React Native Fabric renderer (OSS version) --- .eslintrc.js | 6 ++++++ packages/shared/forks/ReactFeatureFlags.native-oss.js | 5 ++++- scripts/flow/react-native-host-hooks.js | 2 ++ scripts/rollup/validate/eslintrc.rn.js | 2 ++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 7bb59ee17f0c6..fed5a65f40369 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -429,6 +429,12 @@ module.exports = { nativeFabricUIManager: 'readonly', }, }, + { + files: ['packages/shared/forks/**/*.js'], + globals: { + RN$Bridgeless: 'readonly', + }, + }, { files: ['packages/react-server-dom-webpack/**/*.js'], globals: { diff --git a/packages/shared/forks/ReactFeatureFlags.native-oss.js b/packages/shared/forks/ReactFeatureFlags.native-oss.js index 1db47db31b857..70d1d3b5604c1 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-oss.js +++ b/packages/shared/forks/ReactFeatureFlags.native-oss.js @@ -82,7 +82,10 @@ export const enableAsyncActions = false; export const alwaysThrottleRetries = false; -export const useMicrotasksForSchedulingInFabric = false; +const isBridgeless: boolean = + typeof RN$Bridgeless !== 'undefined' && !!RN$Bridgeless; + +export const useMicrotasksForSchedulingInFabric = isBridgeless; export const passChildrenWhenCloningPersistedNodes = false; export const enableUseDeferredValueInitialArg = __EXPERIMENTAL__; export const disableClientCache = true; diff --git a/scripts/flow/react-native-host-hooks.js b/scripts/flow/react-native-host-hooks.js index a6e41c2a51e1c..81fe56a75857a 100644 --- a/scripts/flow/react-native-host-hooks.js +++ b/scripts/flow/react-native-host-hooks.js @@ -167,6 +167,8 @@ declare module 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface' declare module 'react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore' { } +declare const RN$Bridgeless: boolean; + // This is needed for a short term solution. // See https://github.com/facebook/react/pull/15490 for more info declare var nativeFabricUIManager: { diff --git a/scripts/rollup/validate/eslintrc.rn.js b/scripts/rollup/validate/eslintrc.rn.js index ff956ec5e746c..d302296721e51 100644 --- a/scripts/rollup/validate/eslintrc.rn.js +++ b/scripts/rollup/validate/eslintrc.rn.js @@ -42,6 +42,8 @@ module.exports = { // Fabric. See https://github.com/facebook/react/pull/15490 // for more information nativeFabricUIManager: 'readonly', + // RN Bridgeless mode flag + RN$Bridgeless: 'readonly', // Trusted Types trustedTypes: 'readonly', // RN supports this