mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
[react-native] Codemod .getNodeHandle, .getNativeNode to React.findNodeHandle
This commit is contained in:
committed by
Christopher Chedeau
parent
a2f73b4d77
commit
a0440daf98
@@ -67,7 +67,7 @@ var RCTNavigatorItem = createReactNativeComponentClass({
|
||||
var NavigatorTransitionerIOS = React.createClass({
|
||||
requestSchedulingNavigation: function(cb) {
|
||||
RCTNavigatorManager.requestSchedulingJavaScriptNavigation(
|
||||
(this: any).getNodeHandle(),
|
||||
React.findNodeHandle(this),
|
||||
logError,
|
||||
cb
|
||||
);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
var NativeModules = require('NativeModules');
|
||||
var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
|
||||
var React = require('React');
|
||||
var Subscribable = require('Subscribable');
|
||||
var TextInputState = require('TextInputState');
|
||||
|
||||
@@ -350,7 +351,7 @@ var ScrollResponderMixin = {
|
||||
* can also be used to quickly scroll to any element we want to focus
|
||||
*/
|
||||
scrollResponderScrollTo: function(offsetX: number, offsetY: number) {
|
||||
RCTUIManagerDeprecated.scrollTo(this.getNodeHandle(), offsetX, offsetY);
|
||||
RCTUIManagerDeprecated.scrollTo(React.findNodeHandle(this), offsetX, offsetY);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -358,7 +359,7 @@ var ScrollResponderMixin = {
|
||||
* @param {object} rect Should have shape {x, y, width, height}
|
||||
*/
|
||||
scrollResponderZoomTo: function(rect: { x: number; y: number; width: number; height: number; }) {
|
||||
RCTUIManagerDeprecated.zoomToRect(this.getNodeHandle(), rect);
|
||||
RCTUIManagerDeprecated.zoomToRect(React.findNodeHandle(this), rect);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -376,7 +377,7 @@ var ScrollResponderMixin = {
|
||||
this.preventNegativeScrollOffset = !!preventNegativeScrollOffset;
|
||||
RCTUIManager.measureLayout(
|
||||
nodeHandle,
|
||||
this.getNodeHandle(),
|
||||
React.findNodeHandle(this),
|
||||
this.scrollResponderTextInputFocusError,
|
||||
this.scrollResponderInputMeasureAndScrollToKeyboard
|
||||
);
|
||||
|
||||
@@ -305,7 +305,7 @@ var TextInput = React.createClass({
|
||||
|
||||
isFocused: function(): boolean {
|
||||
return TextInputState.currentlyFocusedField() ===
|
||||
this.refs.input.getNativeNode();
|
||||
React.findNodeHandle(this.refs.input);
|
||||
},
|
||||
|
||||
getDefaultProps: function(): DefaultProps {
|
||||
|
||||
@@ -21,22 +21,22 @@ var TextInputState = {
|
||||
/**
|
||||
* Internal state
|
||||
*/
|
||||
_currentlyFocusedID: (null: ?string),
|
||||
_currentlyFocusedID: (null: ?number),
|
||||
|
||||
/**
|
||||
* Returns the ID of the currently focused text field, if one exists
|
||||
* If no text field is focused it returns null
|
||||
*/
|
||||
currentlyFocusedField: function(): ?string {
|
||||
currentlyFocusedField: function(): ?number {
|
||||
return this._currentlyFocusedID;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} TextInputID id of the text field to focus
|
||||
* @param {number} TextInputID id of the text field to focus
|
||||
* Focuses the specified text field
|
||||
* noop if the text field was already focused
|
||||
*/
|
||||
focusTextInput: function(textFieldID: string) {
|
||||
focusTextInput: function(textFieldID: ?number) {
|
||||
if (this._currentlyFocusedID !== textFieldID && textFieldID !== null) {
|
||||
this._currentlyFocusedID = textFieldID;
|
||||
RCTUIManager.focus(textFieldID);
|
||||
@@ -44,11 +44,11 @@ var TextInputState = {
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} textFieldID id of the text field to focus
|
||||
* @param {number} textFieldID id of the text field to focus
|
||||
* Unfocuses the specified text field
|
||||
* noop if it wasn't focused
|
||||
*/
|
||||
blurTextInput: function(textFieldID: string) {
|
||||
blurTextInput: function(textFieldID: ?number) {
|
||||
if (this._currentlyFocusedID === textFieldID && textFieldID !== null) {
|
||||
this._currentlyFocusedID = null;
|
||||
RCTUIManager.blur(textFieldID);
|
||||
|
||||
@@ -143,7 +143,7 @@ var WebView = React.createClass({
|
||||
},
|
||||
|
||||
getWebWiewHandle: function() {
|
||||
return this.refs[RCT_WEBVIEW_REF].getNodeHandle();
|
||||
return React.findNodeHandle(this.refs[RCT_WEBVIEW_REF]);
|
||||
},
|
||||
|
||||
onLoadingStart: function(event) {
|
||||
|
||||
@@ -189,7 +189,7 @@ var WebView = React.createClass({
|
||||
},
|
||||
|
||||
getWebWiewHandle: function(): any {
|
||||
return this.refs[RCT_WEBVIEW_REF].getNodeHandle();
|
||||
return React.findNodeHandle(this.refs[RCT_WEBVIEW_REF]);
|
||||
},
|
||||
|
||||
onLoadingStart: function(event: Event) {
|
||||
|
||||
Reference in New Issue
Block a user