Skip to content

Commit b27fab7

Browse files
dmytrorykunfacebook-github-bot
authored andcommitted
Default to native view configs in bridged mode and to static view configs in bridgeless mode (#39704)
Summary: Pull Request resolved: #39704 Default to native view configs in bridged mode and to static view configs in bridgeless mode. Remove `setRuntimeConfigProvider` calls from RNTester and from the Template. Changelog: [Internal] Reviewed By: RSNara Differential Revision: D49687252 fbshipit-source-id: 140e1c510ba3fbc153978b59c8bb4b4e35bc7571
1 parent c03d520 commit b27fab7

File tree

3 files changed

+10
-22
lines changed

3 files changed

+10
-22
lines changed

packages/react-native/Libraries/NativeComponent/NativeComponentRegistry.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,20 @@ export function get<Config>(
5555
): HostComponent<Config> {
5656
ReactNativeViewConfigRegistry.register(name, () => {
5757
const {native, strict, verify} = getRuntimeConfig?.(name) ?? {
58-
native: true,
58+
native: !global.RN$Bridgeless,
5959
strict: false,
6060
verify: false,
6161
};
6262

63-
const viewConfig = native
64-
? getNativeComponentAttributes(name)
65-
: createViewConfig(viewConfigProvider());
63+
let viewConfig;
64+
if (native) {
65+
viewConfig = getNativeComponentAttributes(name);
66+
} else {
67+
viewConfig = createViewConfig(viewConfigProvider());
68+
if (viewConfig == null) {
69+
viewConfig = getNativeComponentAttributes(name);
70+
}
71+
}
6672

6773
if (verify) {
6874
const nativeViewConfig = native

packages/react-native/template/index.js

-9
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,4 @@ import {AppRegistry} from 'react-native';
66
import App from './App';
77
import {name as appName} from './app.json';
88

9-
if (global.RN$Bridgeless) {
10-
require('react-native/Libraries/NativeComponent/NativeComponentRegistry').setRuntimeConfigProvider(
11-
name => {
12-
// In bridgeless mode, never load native ViewConfig.
13-
return {native: false, strict: false, verify: false};
14-
},
15-
);
16-
}
17-
189
AppRegistry.registerComponent(appName, () => App);

packages/rn-tester/js/RNTesterAppShared.js

-9
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,6 @@ import {BackHandler, StyleSheet, View, useColorScheme} from 'react-native';
2929

3030
// RNTester App currently uses in memory storage for storing navigation state
3131

32-
if (global.RN$Bridgeless) {
33-
require('react-native/Libraries/NativeComponent/NativeComponentRegistry').setRuntimeConfigProvider(
34-
name => {
35-
// In bridgeless mode, never load native ViewConfig.
36-
return {native: false, strict: false, verify: false};
37-
},
38-
);
39-
}
40-
4132
const RNTesterApp = (): React.Node => {
4233
const [state, dispatch] = React.useReducer(
4334
RNTesterNavigationReducer,

0 commit comments

Comments
 (0)