Skip to content

Commit c0fbff7

Browse files
dmytrorykunfacebook-github-bot
authored andcommitted
Static view configs take precedence over native view configs (#39534)
Summary: Pull Request resolved: #39534 Fetching native view configs is computationally intensive work, so if some component has both native and static VCs, we should try static first. This diff changes the `NativeComponentRegistry` so it tries to get static view config first, and then native view config as a fallback. This diff also removes setting `RuntimeConfigProvider` from RNTester. As it was there for the same purpose of inverting that precedence. Changelog: [Internal] Differential Revision: https://internalfb.com/D49413562 fbshipit-source-id: a7a50664e77a726d8f59686b0045cc055f097e39
1 parent 7c4c615 commit c0fbff7

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,18 @@ export function get<Config>(
5454
viewConfigProvider: () => PartialViewConfig,
5555
): HostComponent<Config> {
5656
ReactNativeViewConfigRegistry.register(name, () => {
57-
const {native, strict, verify} = getRuntimeConfig?.(name) ?? {
58-
native: true,
57+
let {native, strict, verify} = getRuntimeConfig?.(name) ?? {
58+
native: false,
5959
strict: false,
6060
verify: false,
6161
};
6262

63-
const viewConfig = native
64-
? getNativeComponentAttributes(name)
65-
: createViewConfig(viewConfigProvider());
63+
let viewConfig = createViewConfig(viewConfigProvider());
64+
if (viewConfig == null) {
65+
// Fallback to native view config.
66+
native = true;
67+
viewConfig = getNativeComponentAttributes(name);
68+
}
6669

6770
if (verify) {
6871
const nativeViewConfig = native

packages/rn-tester/js/RNTesterAppShared.js

Lines changed: 0 additions & 9 deletions
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)