Skip to content

Commit

Permalink
Revert D9930713: Avoid view manager class loads
Browse files Browse the repository at this point in the history
Differential Revision:
D9930713

Original commit changeset: 4aa013f8398d

fbshipit-source-id: 1fed02b41fa9d91f54d1a19f710bdb666701a4a0
  • Loading branch information
ayc1 authored and facebook-github-bot committed Sep 28, 2018
1 parent 5ce2c01 commit e082a61
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 107 deletions.
34 changes: 1 addition & 33 deletions Libraries/ReactNative/UIManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@

const NativeModules = require('NativeModules');
const Platform = require('Platform');
const UIManagerProperties = require('UIManagerProperties');

const defineLazyObjectProperty = require('defineLazyObjectProperty');
const invariant = require('fbjs/lib/invariant');

const {UIManager} = NativeModules;
const viewManagerConfigs = {};

invariant(
UIManager,
Expand All @@ -38,20 +36,7 @@ UIManager.takeSnapshot = function() {
);
};
UIManager.getViewManagerConfig = function(viewManagerName: string) {
if (
viewManagerConfigs[viewManagerName] === undefined &&
UIManager.getConstantsForViewManager
) {
try {
viewManagerConfigs[
viewManagerName
] = UIManager.getConstantsForViewManager(viewManagerName);
} catch (e) {
viewManagerConfigs[viewManagerName] = null;
}
}

return viewManagerConfigs[viewManagerName];
return UIManager[viewManagerName];
};

/**
Expand All @@ -63,7 +48,6 @@ if (Platform.OS === 'ios') {
Object.keys(UIManager).forEach(viewName => {
const viewConfig = UIManager[viewName];
if (viewConfig.Manager) {
viewManagerConfigs[viewName] = viewConfig;
defineLazyObjectProperty(viewConfig, 'Constants', {
get: () => {
const viewManager = NativeModules[viewConfig.Manager];
Expand Down Expand Up @@ -123,20 +107,4 @@ if (Platform.OS === 'ios') {
if (global.__makePartial) global.__makePartial(UIManager);
}

if (__DEV__) {
Object.keys(UIManager).forEach(viewManagerName => {
if (!UIManagerProperties.includes(viewManagerName)) {
defineLazyObjectProperty(UIManager, viewManagerName, {
get: () => {
console.warn(
`Accessing view manager configs directly off UIManager via UIManager['${viewManagerName}'] ` +
`is no longer supported. Use UIManager.getViewManager('${viewManagerName}') instead.`,
);
return UIManager.getViewManagerConfig(viewManagerName);
},
});
}
});
}

module.exports = UIManager;
67 changes: 0 additions & 67 deletions Libraries/ReactNative/UIManagerProperties.js

This file was deleted.

2 changes: 1 addition & 1 deletion Libraries/ReactNative/getNativeComponentAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function attachDefaultEventTypes(viewConfig: any) {
// This is supported on UIManager platforms (ex: Android),
// as lazy view managers are not implemented for all platforms.
// See [UIManager] for details on constants and implementations.
if (UIManager.ViewManagerNames || UIManager.LazyViewManagersEnabled) {
if (UIManager.ViewManagerNames) {
// Lazy view managers enabled.
viewConfig = merge(viewConfig, UIManager.getDefaultEventTypes());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ rn_android_library(
react_native_target("java/com/facebook/react/animation:animation"),
react_native_target("java/com/facebook/react/bridge:bridge"),
react_native_target("java/com/facebook/react/common:common"),
react_native_target("java/com/facebook/react/config:config"),
react_native_target("java/com/facebook/react/common:common"),
react_native_target("java/com/facebook/react/module/annotations:annotations"),
react_native_target("java/com/facebook/react/modules/core:core"),
react_native_target("java/com/facebook/react/modules/i18nmanager:i18nmanager"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;

import com.facebook.react.common.MapBuilder;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.systrace.Systrace;
import com.facebook.systrace.SystraceMessage;
import java.util.List;
import java.util.Map;
Expand All @@ -35,10 +35,7 @@
/* package */ static Map<String, Object> createConstants(
UIManagerModule.ViewManagerResolver resolver) {
Map<String, Object> constants = UIManagerModuleConstants.getConstants();
if (!ReactFeatureFlags.lazilyLoadViewManagers) {
constants.put("ViewManagerNames", resolver.getViewManagerNames());
}
constants.put("LazyViewManagersEnabled", true);
constants.put("ViewManagerNames", resolver.getViewManagerNames());
return constants;
}

Expand Down

0 comments on commit e082a61

Please sign in to comment.