From d9263fbdbb87b6f3b60c59372a1ab32b5b1f15fb Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Fri, 19 Jul 2024 09:37:03 -0700 Subject: [PATCH] Enable ViewConfig validation in RNTester (#45530) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45530 Enable viewconfig validation for RNTester to catch where static and native viewconfigs are mismatched, during development or contribution time. This relies on `useNativeViewConfigsInBridgelessMode()` which is already enabled in `DefaultNewArchitectureEntryPoint` on Android, and seems to be in iOS AppDelegate `RCTRootViewFactory` as well. We put it in an early place in the bundle before first render, since we don't have RNTester preludes right now, but I think it is still early enough? Changelog: [Internal] Reviewed By: javache Differential Revision: D59946366 fbshipit-source-id: ae0c23b13a566489a88a7b4e408f61dce314b003 --- packages/rn-tester/js/RNTesterAppShared.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/rn-tester/js/RNTesterAppShared.js b/packages/rn-tester/js/RNTesterAppShared.js index 0e803557800..4db318d86cd 100644 --- a/packages/rn-tester/js/RNTesterAppShared.js +++ b/packages/rn-tester/js/RNTesterAppShared.js @@ -35,6 +35,18 @@ import { View, useColorScheme, } from 'react-native'; +import * as NativeComponentRegistry from 'react-native/Libraries/NativeComponent/NativeComponentRegistry'; + +// In Bridgeless mode, in dev, enable static view config validator +if (global.RN$Bridgeless === true && __DEV__) { + NativeComponentRegistry.setRuntimeConfigProvider(() => { + return { + native: false, + strict: true, + verify: true, + }; + }); +} // RNTester App currently uses in memory storage for storing navigation state