diff --git a/packages/react-native/Libraries/NativeComponent/NativeComponentRegistry.js b/packages/react-native/Libraries/NativeComponent/NativeComponentRegistry.js index f071f3e6133..f088d2ac7fe 100644 --- a/packages/react-native/Libraries/NativeComponent/NativeComponentRegistry.js +++ b/packages/react-native/Libraries/NativeComponent/NativeComponentRegistry.js @@ -62,14 +62,21 @@ export function get( let viewConfig; if (native) { - viewConfig = getNativeComponentAttributes(name); + viewConfig = + getNativeComponentAttributes(name) ?? + createViewConfig(viewConfigProvider()); } else { - viewConfig = createViewConfig(viewConfigProvider()); - if (viewConfig == null) { - viewConfig = getNativeComponentAttributes(name); - } + viewConfig = + createViewConfig(viewConfigProvider()) ?? + getNativeComponentAttributes(name); } + invariant( + viewConfig != null, + 'NativeComponentRegistry.get: both static and native view config are missing for native component "%s".', + name, + ); + if (verify) { const nativeViewConfig = native ? viewConfig diff --git a/packages/react-native/Libraries/ReactNative/getNativeComponentAttributes.js b/packages/react-native/Libraries/ReactNative/getNativeComponentAttributes.js index d768a648718..209884d959b 100644 --- a/packages/react-native/Libraries/ReactNative/getNativeComponentAttributes.js +++ b/packages/react-native/Libraries/ReactNative/getNativeComponentAttributes.js @@ -19,17 +19,14 @@ const matricesDiffer = require('../Utilities/differ/matricesDiffer'); const pointsDiffer = require('../Utilities/differ/pointsDiffer'); const sizesDiffer = require('../Utilities/differ/sizesDiffer'); const UIManager = require('./UIManager'); -const invariant = require('invariant'); const nullthrows = require('nullthrows'); function getNativeComponentAttributes(uiViewClassName: string): any { const viewConfig = UIManager.getViewManagerConfig(uiViewClassName); - invariant( - viewConfig != null && viewConfig.NativeProps != null, - 'requireNativeComponent: "%s" was not found in the UIManager.', - uiViewClassName, - ); + if (viewConfig == null) { + return null; + } // TODO: This seems like a whole lot of runtime initialization for every // native component that can be either avoided or simplified.