Skip to content

Commit

Permalink
Avoid the call to getViewManagerConfig on deprecatedPropType method
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mdvacca authored and facebook-github-bot committed Jan 26, 2021
1 parent ec7b208 commit e68cf7c
Showing 6 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Libraries/ReactNative/DummyUIManager.js
Original file line number Diff line number Diff line change
@@ -20,6 +20,9 @@ module.exports = {
}
return null;
},
hasViewManagerConfig: (viewManagerName: string): boolean => {
return viewManagerName === 'RCTVirtualText';
},
getConstants: (): {...} => ({}),
getConstantsForViewManager: (viewManagerName: string) => {},
getDefaultEventTypes: (): Array<$FlowFixMe> => [],
3 changes: 3 additions & 0 deletions Libraries/ReactNative/PaperUIManager.js
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions Libraries/ReactNative/UIManager.js
Original file line number Diff line number Diff line change
@@ -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,
1 change: 1 addition & 0 deletions Libraries/ReactNative/UIManagerProperties.js
Original file line number Diff line number Diff line change
@@ -57,6 +57,7 @@ module.exports = [
'AccessibilityEventTypes',
'UIView',
'getViewManagerConfig',
'hasViewManagerConfig',
'blur',
'focus',
'genericBubblingEventTypes',
4 changes: 2 additions & 2 deletions Libraries/Utilities/deprecatedPropType.js
Original file line number Diff line number Diff line change
@@ -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 changes: 3 additions & 0 deletions jest/setup.js
Original file line number Diff line number Diff line change
@@ -69,6 +69,9 @@ jest
};
}
}),
hasViewManagerConfig: jest.fn(name => {
return true;
}),
measure: jest.fn(),
manageChildren: jest.fn(),
removeSubviewsFromContainerWithID: jest.fn(),

0 comments on commit e68cf7c

Please sign in to comment.