diff --git a/packages/react-native/Libraries/NativeComponent/NativeComponentRegistry.js b/packages/react-native/Libraries/NativeComponent/NativeComponentRegistry.js index ace5eb38e605cd..46dab04b7723a0 100644 --- a/packages/react-native/Libraries/NativeComponent/NativeComponentRegistry.js +++ b/packages/react-native/Libraries/NativeComponent/NativeComponentRegistry.js @@ -55,14 +55,20 @@ export function get( ): HostComponent { ReactNativeViewConfigRegistry.register(name, () => { const {native, strict, verify} = getRuntimeConfig?.(name) ?? { - native: true, + native: !global.RN$Bridgeless, strict: false, verify: false, }; - const viewConfig = native - ? getNativeComponentAttributes(name) - : createViewConfig(viewConfigProvider()); + let viewConfig; + if (native) { + viewConfig = getNativeComponentAttributes(name); + } else { + viewConfig = createViewConfig(viewConfigProvider()); + if (viewConfig == null) { + viewConfig = getNativeComponentAttributes(name); + } + } if (verify) { const nativeViewConfig = native diff --git a/packages/react-native/template/index.js b/packages/react-native/template/index.js index cd33b74bb3aa34..a850d031de7911 100644 --- a/packages/react-native/template/index.js +++ b/packages/react-native/template/index.js @@ -6,13 +6,4 @@ import {AppRegistry} from 'react-native'; import App from './App'; import {name as appName} from './app.json'; -if (global.RN$Bridgeless) { - require('react-native/Libraries/NativeComponent/NativeComponentRegistry').setRuntimeConfigProvider( - name => { - // In bridgeless mode, never load native ViewConfig. - return {native: false, strict: false, verify: false}; - }, - ); -} - AppRegistry.registerComponent(appName, () => App); diff --git a/packages/rn-tester/js/RNTesterAppShared.js b/packages/rn-tester/js/RNTesterAppShared.js index 0949aafca08d92..3cd8e9d9afad5a 100644 --- a/packages/rn-tester/js/RNTesterAppShared.js +++ b/packages/rn-tester/js/RNTesterAppShared.js @@ -29,15 +29,6 @@ import {BackHandler, StyleSheet, View, useColorScheme} from 'react-native'; // RNTester App currently uses in memory storage for storing navigation state -if (global.RN$Bridgeless) { - require('react-native/Libraries/NativeComponent/NativeComponentRegistry').setRuntimeConfigProvider( - name => { - // In bridgeless mode, never load native ViewConfig. - return {native: false, strict: false, verify: false}; - }, - ); -} - const RNTesterApp = (): React.Node => { const [state, dispatch] = React.useReducer( RNTesterNavigationReducer,