From 1ca63e3e3dff6639f4efde74583145f9fa53759a Mon Sep 17 00:00:00 2001 From: Peter Abbondanzo Date: Mon, 15 Jul 2024 07:00:35 -0700 Subject: [PATCH] Check nullability of native view config before validation (#45420) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45420 Devex improvement to skip validation when no native view config exists. Redbox is still hit, showing the true error. See test plan below before/after Changelog: [Internal] Reviewed By: javache Differential Revision: D59702501 fbshipit-source-id: 9aada9813c2930ee2b4bb23e5ba8a3e546c4e9af --- .../NativeComponent/NativeComponentRegistry.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/react-native/Libraries/NativeComponent/NativeComponentRegistry.js b/packages/react-native/Libraries/NativeComponent/NativeComponentRegistry.js index f088d2ac7fe..528820399be 100644 --- a/packages/react-native/Libraries/NativeComponent/NativeComponentRegistry.js +++ b/packages/react-native/Libraries/NativeComponent/NativeComponentRegistry.js @@ -11,6 +11,7 @@ import type { HostComponent, PartialViewConfig, + ViewConfig, } from '../Renderer/shims/ReactNativeTypes'; import getNativeComponentAttributes from '../ReactNative/getNativeComponentAttributes'; @@ -60,7 +61,7 @@ export function get( verify: false, }; - let viewConfig; + let viewConfig: ViewConfig; if (native) { viewConfig = getNativeComponentAttributes(name) ?? @@ -81,7 +82,13 @@ export function get( const nativeViewConfig = native ? viewConfig : getNativeComponentAttributes(name); - const staticViewConfig = native + + if (nativeViewConfig == null) { + // Defer to static view config if native view config is missing. + return viewConfig; + } + + const staticViewConfig: ViewConfig = native ? createViewConfig(viewConfigProvider()) : viewConfig;