[react-native] Codemod .getNodeHandle, .getNativeNode to React.findNodeHandle

This commit is contained in:
Ben Alpert
2015-05-12 18:55:13 -07:00
committed by Christopher Chedeau
parent a2f73b4d77
commit a0440daf98
11 changed files with 33 additions and 29 deletions

View File

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

View File

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