From 613ca146122bf235aea110b436dbe17ba0912a1d Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Thu, 7 Apr 2016 19:43:49 -0700 Subject: [PATCH] React.findNodeHandle -> ReactNative.findNodeHandle Summary:Since the React 0.14 split of modules, the findNodeHandle feature is part of the renderer and not the generic React API. This just greps for React.findNodeHandle and replace them with ReactNative.findNodeHandle. I fixed up the imports manually. I also found two callers each of ReactNative.createClass and React.render with the exception of downstream and examples will fix them separately. I'll need to find more things like `var { PropTypes } = ReactNative;` separately. I think this is a good start though. Reviewed By: vjeux Differential Revision: D3149356 fb-gh-sync-id: 50ed60bc67270b16f561d4c641f2f19e85724d3b fbshipit-source-id: 50ed60bc67270b16f561d4c641f2f19e85724d3b --- .../DrawerAndroid/DrawerLayoutAndroid.android.js | 3 ++- Libraries/Components/Navigation/NavigatorIOS.ios.js | 3 ++- Libraries/Components/ScrollResponder.js | 5 +++-- Libraries/Components/ScrollView/ScrollView.js | 7 ++++--- Libraries/Components/TextInput/TextInput.js | 3 ++- .../Touchable/TouchableNativeFeedback.android.js | 5 +++-- .../Components/ViewPager/ViewPagerAndroid.android.js | 5 +++-- Libraries/Components/WebView/WebView.android.js | 3 ++- Libraries/Components/WebView/WebView.ios.js | 3 ++- Libraries/CustomComponents/ListView/ListView.js | 3 ++- Libraries/Inspector/Inspector.js | 3 ++- Libraries/Portal/Portal.js | 10 ++++++++-- Libraries/ReactIOS/renderApplication.android.js | 5 +++-- Libraries/ReactIOS/renderApplication.ios.js | 5 +++-- docs/Accessibility.md | 2 +- 15 files changed, 42 insertions(+), 23 deletions(-) diff --git a/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js b/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js index a381a781910..63944161b05 100644 --- a/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +++ b/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js @@ -14,6 +14,7 @@ var ColorPropType = require('ColorPropType'); var NativeMethodsMixin = require('NativeMethodsMixin'); var Platform = require('Platform'); var React = require('React'); +var ReactNative = require('ReactNative'); var ReactPropTypes = require('ReactPropTypes'); var StatusBar = require('StatusBar'); var StyleSheet = require('StyleSheet'); @@ -239,7 +240,7 @@ var DrawerLayoutAndroid = React.createClass({ }, _getDrawerLayoutHandle: function() { - return React.findNodeHandle(this.refs[RK_DRAWER_REF]); + return ReactNative.findNodeHandle(this.refs[RK_DRAWER_REF]); }, // Update the StatusBar component background color one frame after creating the diff --git a/Libraries/Components/Navigation/NavigatorIOS.ios.js b/Libraries/Components/Navigation/NavigatorIOS.ios.js index c4a2405258d..6ed33686076 100644 --- a/Libraries/Components/Navigation/NavigatorIOS.ios.js +++ b/Libraries/Components/Navigation/NavigatorIOS.ios.js @@ -16,6 +16,7 @@ var Image = require('Image'); var NavigationContext = require('NavigationContext'); var RCTNavigatorManager = require('NativeModules').NavigatorManager; var React = require('React'); +var ReactNative = require('ReactNative'); var StaticContainer = require('StaticContainer.react'); var StyleSheet = require('StyleSheet'); var View = require('View'); @@ -37,7 +38,7 @@ function getuid() { var NavigatorTransitionerIOS = React.createClass({ requestSchedulingNavigation: function(cb) { RCTNavigatorManager.requestSchedulingJavaScriptNavigation( - React.findNodeHandle(this), + ReactNative.findNodeHandle(this), logError, cb ); diff --git a/Libraries/Components/ScrollResponder.js b/Libraries/Components/ScrollResponder.js index bb249f9226a..62b291933da 100644 --- a/Libraries/Components/ScrollResponder.js +++ b/Libraries/Components/ScrollResponder.js @@ -15,6 +15,7 @@ var Dimensions = require('Dimensions'); var Platform = require('Platform'); var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); var React = require('React'); +var ReactNative = require('ReactNative'); var Subscribable = require('Subscribable'); var TextInputState = require('TextInputState'); var UIManager = require('UIManager'); @@ -354,7 +355,7 @@ var ScrollResponderMixin = { scrollResponderGetScrollableNode: function(): any { return this.getScrollableNode ? this.getScrollableNode() : - React.findNodeHandle(this); + ReactNative.findNodeHandle(this); }, /** @@ -430,7 +431,7 @@ var ScrollResponderMixin = { this.preventNegativeScrollOffset = !!preventNegativeScrollOffset; UIManager.measureLayout( nodeHandle, - React.findNodeHandle(this.getInnerViewNode()), + ReactNative.findNodeHandle(this.getInnerViewNode()), this.scrollResponderTextInputFocusError, this.scrollResponderInputMeasureAndScrollToKeyboard ); diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index 7d513b15ec3..387ee46f94e 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -18,6 +18,7 @@ var PointPropType = require('PointPropType'); var RCTScrollView = require('NativeModules').UIManager.RCTScrollView; var RCTScrollViewManager = require('NativeModules').ScrollViewManager; var React = require('React'); +var ReactNative = require('ReactNative'); var ScrollResponder = require('ScrollResponder'); var StyleSheet = require('StyleSheet'); var StyleSheetPropType = require('StyleSheetPropType'); @@ -342,7 +343,7 @@ var ScrollView = React.createClass({ endRefreshing: function() { RCTScrollViewManager.endRefreshing( - React.findNodeHandle(this) + ReactNative.findNodeHandle(this) ); }, @@ -357,11 +358,11 @@ var ScrollView = React.createClass({ }, getScrollableNode: function(): any { - return React.findNodeHandle(this.refs[SCROLLVIEW]); + return ReactNative.findNodeHandle(this.refs[SCROLLVIEW]); }, getInnerViewNode: function(): any { - return React.findNodeHandle(this.refs[INNERVIEW]); + return ReactNative.findNodeHandle(this.refs[INNERVIEW]); }, /** diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index 366bbce6bf6..1b34b88bb74 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -17,6 +17,7 @@ var NativeMethodsMixin = require('NativeMethodsMixin'); var Platform = require('Platform'); var PropTypes = require('ReactPropTypes'); var React = require('React'); +var ReactNative = require('ReactNative'); var ReactChildren = require('ReactChildren'); var StyleSheet = require('StyleSheet'); var Text = require('Text'); @@ -320,7 +321,7 @@ var TextInput = React.createClass({ isFocused: function(): boolean { return TextInputState.currentlyFocusedField() === - React.findNodeHandle(this.refs.input); + ReactNative.findNodeHandle(this.refs.input); }, contextTypes: { diff --git a/Libraries/Components/Touchable/TouchableNativeFeedback.android.js b/Libraries/Components/Touchable/TouchableNativeFeedback.android.js index 37b010e25ff..f174ab3d39c 100644 --- a/Libraries/Components/Touchable/TouchableNativeFeedback.android.js +++ b/Libraries/Components/Touchable/TouchableNativeFeedback.android.js @@ -12,6 +12,7 @@ var PropTypes = require('ReactPropTypes'); var React = require('React'); +var ReactNative = require('ReactNative'); var ReactNativeViewAttributes = require('ReactNativeViewAttributes'); var Touchable = require('Touchable'); var TouchableWithoutFeedback = require('TouchableWithoutFeedback'); @@ -187,7 +188,7 @@ var TouchableNativeFeedback = React.createClass({ _dispatchHotspotUpdate: function(destX, destY) { UIManager.dispatchViewManagerCommand( - React.findNodeHandle(this), + ReactNative.findNodeHandle(this), UIManager.RCTView.Commands.hotspotUpdate, [destX || 0, destY || 0] ); @@ -195,7 +196,7 @@ var TouchableNativeFeedback = React.createClass({ _dispatchPressedStateChange: function(pressed) { UIManager.dispatchViewManagerCommand( - React.findNodeHandle(this), + ReactNative.findNodeHandle(this), UIManager.RCTView.Commands.setPressed, [pressed] ); diff --git a/Libraries/Components/ViewPager/ViewPagerAndroid.android.js b/Libraries/Components/ViewPager/ViewPagerAndroid.android.js index 03dc9021106..c43ee197045 100644 --- a/Libraries/Components/ViewPager/ViewPagerAndroid.android.js +++ b/Libraries/Components/ViewPager/ViewPagerAndroid.android.js @@ -12,6 +12,7 @@ 'use strict'; var React = require('React'); +var ReactNative = require('ReactNative'); var ReactElement = require('ReactElement'); var ReactPropTypes = require('ReactPropTypes'); var UIManager = require('UIManager'); @@ -192,7 +193,7 @@ var ViewPagerAndroid = React.createClass({ */ setPage: function(selectedPage: number) { UIManager.dispatchViewManagerCommand( - React.findNodeHandle(this), + ReactNative.findNodeHandle(this), UIManager.AndroidViewPager.Commands.setPage, [selectedPage], ); @@ -204,7 +205,7 @@ var ViewPagerAndroid = React.createClass({ */ setPageWithoutAnimation: function(selectedPage: number) { UIManager.dispatchViewManagerCommand( - React.findNodeHandle(this), + ReactNative.findNodeHandle(this), UIManager.AndroidViewPager.Commands.setPageWithoutAnimation, [selectedPage], ); diff --git a/Libraries/Components/WebView/WebView.android.js b/Libraries/Components/WebView/WebView.android.js index 89b7b4848ea..05b1cae684d 100644 --- a/Libraries/Components/WebView/WebView.android.js +++ b/Libraries/Components/WebView/WebView.android.js @@ -13,6 +13,7 @@ var EdgeInsetsPropType = require('EdgeInsetsPropType'); var ProgressBarAndroid = require('ProgressBarAndroid'); var React = require('React'); +var ReactNative = require('ReactNative'); var ReactNativeViewAttributes = require('ReactNativeViewAttributes'); var StyleSheet = require('StyleSheet'); var UIManager = require('UIManager'); @@ -274,7 +275,7 @@ var WebView = React.createClass({ }, getWebViewHandle: function() { - return React.findNodeHandle(this.refs[RCT_WEBVIEW_REF]); + return ReactNative.findNodeHandle(this.refs[RCT_WEBVIEW_REF]); }, onLoadingStart: function(event) { diff --git a/Libraries/Components/WebView/WebView.ios.js b/Libraries/Components/WebView/WebView.ios.js index acc52d9590d..60abb8ffac0 100644 --- a/Libraries/Components/WebView/WebView.ios.js +++ b/Libraries/Components/WebView/WebView.ios.js @@ -14,6 +14,7 @@ var ActivityIndicatorIOS = require('ActivityIndicatorIOS'); var EdgeInsetsPropType = require('EdgeInsetsPropType'); var React = require('React'); +var ReactNative = require('ReactNative'); var StyleSheet = require('StyleSheet'); var Text = require('Text'); var UIManager = require('UIManager'); @@ -363,7 +364,7 @@ var WebView = React.createClass({ }, getWebViewHandle: function(): any { - return React.findNodeHandle(this.refs[RCT_WEBVIEW_REF]); + return ReactNative.findNodeHandle(this.refs[RCT_WEBVIEW_REF]); }, onLoadingStart: function(event: Event) { diff --git a/Libraries/CustomComponents/ListView/ListView.js b/Libraries/CustomComponents/ListView/ListView.js index 314bd616eb4..93ead150170 100644 --- a/Libraries/CustomComponents/ListView/ListView.js +++ b/Libraries/CustomComponents/ListView/ListView.js @@ -33,6 +33,7 @@ var ListViewDataSource = require('ListViewDataSource'); var React = require('React'); +var ReactNative = require('ReactNative'); var RCTScrollViewManager = require('NativeModules').ScrollViewManager; var ScrollView = require('ScrollView'); var ScrollResponder = require('ScrollResponder'); @@ -476,7 +477,7 @@ var ListView = React.createClass({ // every platform RCTScrollViewManager && RCTScrollViewManager.calculateChildFrames && RCTScrollViewManager.calculateChildFrames( - React.findNodeHandle(scrollComponent), + ReactNative.findNodeHandle(scrollComponent), this._updateVisibleRows, ); }, diff --git a/Libraries/Inspector/Inspector.js b/Libraries/Inspector/Inspector.js index c72da8e7e76..d65bc3e9986 100644 --- a/Libraries/Inspector/Inspector.js +++ b/Libraries/Inspector/Inspector.js @@ -16,6 +16,7 @@ var InspectorOverlay = require('InspectorOverlay'); var InspectorPanel = require('InspectorPanel'); var InspectorUtils = require('InspectorUtils'); var React = require('React'); +var ReactNative = require('ReactNative'); var StyleSheet = require('StyleSheet'); var UIManager = require('NativeModules').UIManager; var View = require('View'); @@ -101,7 +102,7 @@ class Inspector extends React.Component { // if we inspect a stateless component we can't use the getPublicInstance method // therefore we use the internal _instance property directly. var publicInstance = instance._instance || {}; - UIManager.measure(React.findNodeHandle(instance), (x, y, width, height, left, top) => { + UIManager.measure(ReactNative.findNodeHandle(instance), (x, y, width, height, left, top) => { this.setState({ inspected: { frame: {left, top, width, height}, diff --git a/Libraries/Portal/Portal.js b/Libraries/Portal/Portal.js index f6ed4c8f786..cfe278f15f6 100644 --- a/Libraries/Portal/Portal.js +++ b/Libraries/Portal/Portal.js @@ -1,5 +1,10 @@ /** - * Copyright 2004-present Facebook. All Rights Reserved. + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule Portal * @flow @@ -8,6 +13,7 @@ var Platform = require('Platform'); var React = require('React'); +var ReactNative = require('ReactNative'); var StyleSheet = require('StyleSheet'); var UIManager = require('UIManager'); var View = require('View'); @@ -136,7 +142,7 @@ var Portal = React.createClass({ setTimeout(() => { if (this._getOpenModals().length > 0) { UIManager.sendAccessibilityEvent( - React.findNodeHandle(this), + ReactNative.findNodeHandle(this), UIManager.AccessibilityEventTypes.typeWindowStateChanged); } }, 0); diff --git a/Libraries/ReactIOS/renderApplication.android.js b/Libraries/ReactIOS/renderApplication.android.js index 03191bbc037..f386f0aed3f 100644 --- a/Libraries/ReactIOS/renderApplication.android.js +++ b/Libraries/ReactIOS/renderApplication.android.js @@ -15,6 +15,7 @@ var Inspector = require('Inspector'); var Portal = require('Portal'); var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); var React = require('React'); +var ReactNative = require('ReactNative'); var StyleSheet = require('StyleSheet'); var Subscribable = require('Subscribable'); var View = require('View'); @@ -41,7 +42,7 @@ var AppContainer = React.createClass({ toggleElementInspector: function() { this.setState({ inspectorVisible: !this.state.inspectorVisible, - rootNodeHandle: React.findNodeHandle(this.refs.main), + rootNodeHandle: ReactNative.findNodeHandle(this.refs.main), }); }, @@ -115,7 +116,7 @@ function renderApplication( rootTag, 'Expect to have a valid rootTag, instead got ', rootTag ); - React.render( + ReactNative.render( ; this.setState({inspector}); }, @@ -75,7 +76,7 @@ function renderApplication( 'Expect to have a valid rootTag, instead got ', rootTag ); /* eslint-disable jsx-no-undef-with-namespace */ - React.render( + ReactNative.render(