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
This commit is contained in:
Peter Abbondanzo
2024-07-15 07:00:35 -07:00
committed by Facebook GitHub Bot
parent 7ff1e447fd
commit 1ca63e3e3d
@@ -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<Config>(
verify: false,
};
let viewConfig;
let viewConfig: ViewConfig;
if (native) {
viewConfig =
getNativeComponentAttributes(name) ??
@@ -81,7 +82,13 @@ export function get<Config>(
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;