From 9d0242fdc3e9728f6afef5d49c712d24a9c8f49f Mon Sep 17 00:00:00 2001 From: Nick Lockwood Date: Sat, 30 Jan 2016 07:35:36 -0800 Subject: [PATCH] Replace direct access of NativeModules.UIManager with require('UIManager') Summary: public Due to the cross-platform polyfills we have added (and will add in future) to `UIManager.js`, accessing UIManager directly via NativeModules instead of importing the wrapper is discouraged. This diff fixes a few places where we were doing this inside our own modules. Note: As a general policy, we should avoid accessing modules via NativeModules anyway. Using wrapper classes allows us to provide static declarations for all the native methods and properties, which can be checked at build time by flow. If we access the modules directly, those interfaces are only known at runtime. Reviewed By: vjeux Differential Revision: D2881300 fb-gh-sync-id: 6737358ea8ea6d722cc1941a4b9fa0123a87fc29 --- Libraries/Components/DatePicker/DatePickerIOS.ios.js | 2 +- Libraries/Components/ScrollResponder.js | 3 ++- Libraries/RCTTest/SnapshotViewIOS.ios.js | 3 ++- docs/NativeComponentsIOS.md | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Libraries/Components/DatePicker/DatePickerIOS.ios.js b/Libraries/Components/DatePicker/DatePickerIOS.ios.js index 3516ae35d..c436abbbb 100644 --- a/Libraries/Components/DatePicker/DatePickerIOS.ios.js +++ b/Libraries/Components/DatePicker/DatePickerIOS.ios.js @@ -16,7 +16,7 @@ var NativeMethodsMixin = require('NativeMethodsMixin'); var PropTypes = require('ReactPropTypes'); var React = require('React'); -var RCTDatePickerIOSConsts = require('NativeModules').UIManager.RCTDatePicker.Constants; +var RCTDatePickerIOSConsts = require('UIManager').RCTDatePicker.Constants; var StyleSheet = require('StyleSheet'); var View = require('View'); diff --git a/Libraries/Components/ScrollResponder.js b/Libraries/Components/ScrollResponder.js index baa3336a0..b385b87b8 100644 --- a/Libraries/Components/ScrollResponder.js +++ b/Libraries/Components/ScrollResponder.js @@ -17,8 +17,9 @@ var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); var React = require('React'); var Subscribable = require('Subscribable'); var TextInputState = require('TextInputState'); +var UIManager = require('UIManager'); -var { UIManager, ScrollViewManager } = require('NativeModules'); +var { ScrollViewManager } = require('NativeModules'); var invariant = require('invariant'); var warning = require('warning'); diff --git a/Libraries/RCTTest/SnapshotViewIOS.ios.js b/Libraries/RCTTest/SnapshotViewIOS.ios.js index 3ecefdc3d..3cd8bf04a 100644 --- a/Libraries/RCTTest/SnapshotViewIOS.ios.js +++ b/Libraries/RCTTest/SnapshotViewIOS.ios.js @@ -13,7 +13,8 @@ var React = require('React'); var StyleSheet = require('StyleSheet'); -var { TestModule, UIManager } = require('NativeModules'); +var { TestModule } = require('NativeModules'); +var UIManager = require('UIManager'); var View = require('View'); var requireNativeComponent = require('requireNativeComponent'); diff --git a/docs/NativeComponentsIOS.md b/docs/NativeComponentsIOS.md index ebdbc2f71..fffb06eca 100644 --- a/docs/NativeComponentsIOS.md +++ b/docs/NativeComponentsIOS.md @@ -302,7 +302,7 @@ Since all our native react views are subclasses of `UIView`, most style attribut ```javascript // DatePickerIOS.ios.js -var RCTDatePickerIOSConsts = require('react-native').NativeModules.UIManager.RCTDatePicker.Constants; +var RCTDatePickerIOSConsts = require('react-native').UIManager.RCTDatePicker.Constants; ... render: function() { return (