mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
3/5 For codegenNativeComponent, with SVC enabled, use UIManager hasViewManagerConfig instead of getViewManagerConfig
Summary: With SVC enabled for codegenNativeComponent, use `UIManager.hasViewManagerConfig(viewManagerName)` instead of `UIManager.getViewManagerConfig(viewManagerName)` to check for whether the native component is in the app BUCK binary. This is safe because `global.__fbStaticViewConfig` is gated with MC, and the purpose of SVCs is to stop using `getViewManagerConfig` to get view configs from the Paper view managers. Currently no QEs have SVCs enabled. Changelog: [Fabric][JS] For codegenNativeComponent, with SVC enabled, use UIManager hasViewManagerConfig instead of getViewManagerConfig Reviewed By: RSNara Differential Revision: D33511365 fbshipit-source-id: 58c7020903137e2b5c80ef34a956be04de51628b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
85ecb0043f
commit
7c63e0d5bc
+20
-5
@@ -127,6 +127,10 @@ export default NativeComponentRegistry.get(nativeComponentName, () => VIEW_CONFI
|
||||
`.trim();
|
||||
};
|
||||
|
||||
// If static view configs are enabled, get whether the native component exists
|
||||
// in the app binary using hasViewManagerConfig() instead of getViewManagerConfig().
|
||||
// Old getViewManagerConfig() checks for the existance of the native Paper view manager.
|
||||
// New hasViewManagerConfig() queries Fabric’s native component registry directly.
|
||||
const DeprecatedComponentNameCheckTemplate = ({
|
||||
componentName,
|
||||
paperComponentNameDeprecated,
|
||||
@@ -135,12 +139,23 @@ const DeprecatedComponentNameCheckTemplate = ({
|
||||
paperComponentNameDeprecated: string,
|
||||
}) =>
|
||||
`
|
||||
if (UIManager.getViewManagerConfig('${componentName}')) {
|
||||
nativeComponentName = '${componentName}';
|
||||
} else if (UIManager.getViewManagerConfig('${paperComponentNameDeprecated}')) {
|
||||
nativeComponentName = '${paperComponentNameDeprecated}';
|
||||
const staticViewConfigsEnabled = global.__fbStaticViewConfig === true;
|
||||
if (staticViewConfigsEnabled) {
|
||||
if (UIManager.hasViewManagerConfig('${componentName}')) {
|
||||
nativeComponentName = '${componentName}';
|
||||
} else if (UIManager.hasViewManagerConfig('${paperComponentNameDeprecated}')) {
|
||||
nativeComponentName = '${paperComponentNameDeprecated}';
|
||||
} else {
|
||||
throw new Error('Failed to find native component for either "${componentName}" or "${paperComponentNameDeprecated}", with SVC enabled.');
|
||||
}
|
||||
} else {
|
||||
throw new Error('Failed to find native component for either "${componentName}" or "${paperComponentNameDeprecated}"');
|
||||
if (UIManager.getViewManagerConfig('${componentName}')) {
|
||||
nativeComponentName = '${componentName}';
|
||||
} else if (UIManager.getViewManagerConfig('${paperComponentNameDeprecated}')) {
|
||||
nativeComponentName = '${paperComponentNameDeprecated}';
|
||||
} else {
|
||||
throw new Error('Failed to find native component for either "${componentName}" or "${paperComponentNameDeprecated}", with SVC disabled.');
|
||||
}
|
||||
}
|
||||
`.trim();
|
||||
|
||||
|
||||
+16
-5
@@ -973,12 +973,23 @@ const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/
|
||||
const {UIManager} = require(\\"react-native\\")
|
||||
|
||||
let nativeComponentName = 'NativeComponentName';
|
||||
if (UIManager.getViewManagerConfig('NativeComponentName')) {
|
||||
nativeComponentName = 'NativeComponentName';
|
||||
} else if (UIManager.getViewManagerConfig('DeprecatedNativeComponentName')) {
|
||||
nativeComponentName = 'DeprecatedNativeComponentName';
|
||||
const staticViewConfigsEnabled = global.__fbStaticViewConfig === true;
|
||||
if (staticViewConfigsEnabled) {
|
||||
if (UIManager.hasViewManagerConfig('NativeComponentName')) {
|
||||
nativeComponentName = 'NativeComponentName';
|
||||
} else if (UIManager.hasViewManagerConfig('DeprecatedNativeComponentName')) {
|
||||
nativeComponentName = 'DeprecatedNativeComponentName';
|
||||
} else {
|
||||
throw new Error('Failed to find native component for either \\"NativeComponentName\\" or \\"DeprecatedNativeComponentName\\", with SVC enabled.');
|
||||
}
|
||||
} else {
|
||||
throw new Error('Failed to find native component for either \\"NativeComponentName\\" or \\"DeprecatedNativeComponentName\\"');
|
||||
if (UIManager.getViewManagerConfig('NativeComponentName')) {
|
||||
nativeComponentName = 'NativeComponentName';
|
||||
} else if (UIManager.getViewManagerConfig('DeprecatedNativeComponentName')) {
|
||||
nativeComponentName = 'DeprecatedNativeComponentName';
|
||||
} else {
|
||||
throw new Error('Failed to find native component for either \\"NativeComponentName\\" or \\"DeprecatedNativeComponentName\\", with SVC disabled.');
|
||||
}
|
||||
}
|
||||
export default NativeComponentRegistry.get(nativeComponentName, () => ({
|
||||
uiViewClassName: 'NativeComponentName',
|
||||
|
||||
Reference in New Issue
Block a user