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
This commit is contained in:
Sebastian Markbage 2016-04-07 19:43:49 -07:00 committed by Facebook Github Bot 5
parent 6038040f8e
commit 613ca14612
15 changed files with 42 additions and 23 deletions

View File

@ -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

View File

@ -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
);

View File

@ -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
);

View File

@ -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]);
},
/**

View File

@ -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: {

View File

@ -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]
);

View File

@ -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],
);

View File

@ -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) {

View File

@ -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) {

View File

@ -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,
);
},

View File

@ -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},

View File

@ -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);

View File

@ -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<D, P, S>(
rootTag,
'Expect to have a valid rootTag, instead got ', rootTag
);
React.render(
ReactNative.render(
<AppContainer
rootComponent={RootComponent}
initialProps={initialProps}

View File

@ -14,6 +14,7 @@
var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
var React = require('React');
var ReactNative = require('ReactNative');
var StyleSheet = require('StyleSheet');
var Subscribable = require('Subscribable');
var View = require('View');
@ -35,7 +36,7 @@ var AppContainer = React.createClass({
? null
: <Inspector
rootTag={this.props.rootTag}
inspectedViewTag={React.findNodeHandle(this.refs.main)}
inspectedViewTag={ReactNative.findNodeHandle(this.refs.main)}
/>;
this.setState({inspector});
},
@ -75,7 +76,7 @@ function renderApplication<D, P, S>(
'Expect to have a valid rootTag, instead got ', rootTag
);
/* eslint-disable jsx-no-undef-with-namespace */
React.render(
ReactNative.render(
<AppContainer rootTag={rootTag}>
<RootComponent
{...initialProps}

View File

@ -146,7 +146,7 @@ _onPress: function() {
“radiobutton_unchecked” : “radiobutton_checked”;
if (this.state.radioButton === “radiobutton_checked”) {
RCTUIManager.sendAccessibilityEvent(
React.findNodeHandle(this),
ReactNative.findNodeHandle(this),
RCTUIManager.AccessibilityEventTypes.typeViewClicked);
}
}