Skip to content

Commit

Permalink
Default to native view configs in bridged mode and to static view con…
Browse files Browse the repository at this point in the history
…figs in bridgeless mode (#39704)

Summary:

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
  • Loading branch information
Dmitry Rykun authored and facebook-github-bot committed Oct 2, 2023
1 parent a59b947 commit 0aecdc2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,20 @@ export function get<Config>(
): HostComponent<Config> {
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
Expand Down
9 changes: 0 additions & 9 deletions packages/react-native/template/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
9 changes: 0 additions & 9 deletions packages/rn-tester/js/RNTesterAppShared.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0aecdc2

Please sign in to comment.