Avoid the call to getViewManagerConfig on deprecatedPropType method

Summary:
This diff removes the call to UIManager.getViewManagerConfig into the deprecatedPropType method when static view configs are enabled

This was necessary to avoid innecessary calls to UIManager.getViewManagerConfig and to avoid loading UIManagerModule classes when static view configs are enabled

changelog: [internal] internal

Reviewed By: fkgozali, yungsters

Differential Revision: D26040855

fbshipit-source-id: 82cad9f4abe9898e781fd989ebaa03497dad926b
This commit is contained in:
David Vacca
2021-01-26 14:05:33 -08:00
committed by Facebook GitHub Bot
parent ec7b2085d8
commit e68cf7cee9
6 changed files with 13 additions and 2 deletions
+3
View File
@@ -20,6 +20,9 @@ module.exports = {
}
return null;
},
hasViewManagerConfig: (viewManagerName: string): boolean => {
return viewManagerName === 'RCTVirtualText';
},
getConstants: (): {...} => ({}),
getConstantsForViewManager: (viewManagerName: string) => {},
getDefaultEventTypes: (): Array<$FlowFixMe> => [],
+3
View File
@@ -97,6 +97,9 @@ const UIManagerJS = {
getViewManagerConfig(viewManagerName: string): any {
return getViewManagerConfig(viewManagerName);
},
hasViewManagerConfig(viewManagerName: string): boolean {
return getViewManagerConfig(viewManagerName) != null;
},
};
// TODO (T45220498): Remove this.
+1
View File
@@ -15,6 +15,7 @@ import type {Spec} from './NativeUIManager';
interface UIManagerJSInterface extends Spec {
+getViewManagerConfig: (viewManagerName: string) => Object;
+hasViewManagerConfig: (viewManagerName: string) => boolean;
+createView: (
reactTag: ?number,
viewName: string,
@@ -57,6 +57,7 @@ module.exports = [
'AccessibilityEventTypes',
'UIView',
'getViewManagerConfig',
'hasViewManagerConfig',
'blur',
'focus',
'genericBubblingEventTypes',
+2 -2
View File
@@ -10,7 +10,7 @@
'use strict';
const UIManager = require('../ReactNative/UIManager');
import UIManager from '../ReactNative/UIManager';
/**
* Adds a deprecation warning when the prop is used.
@@ -23,7 +23,7 @@ function deprecatedPropType(
// Don't warn for native components.
if (
!global.RN$Bridgeless &&
!UIManager.getViewManagerConfig(componentName) &&
UIManager.hasViewManagerConfig(componentName) &&
props[propName] !== undefined
) {
console.warn(
+3
View File
@@ -69,6 +69,9 @@ jest
};
}
}),
hasViewManagerConfig: jest.fn(name => {
return true;
}),
measure: jest.fn(),
manageChildren: jest.fn(),
removeSubviewsFromContainerWithID: jest.fn(),