From ce3b7b8204dad0fd62a76a0ce66472eca4b25bc8 Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Thu, 17 May 2018 11:18:36 -0700 Subject: [PATCH] Bring back TextInput.State, deprecate focusTextInput and blurTextInput Summary: a275eac56e21b8f3631bcd03ace86c07a3b0c0ba removed TextInput.State but we should keep it as it was a public-ish API and we don't have any migration plan off it. Also bring back `focusTextInput` and `blurTextInput` with a deprecation warning. Tested TextInput.State is back [GENERAL][ENHANCEMENT][TextInput] - Bring back TextInput.State, deprecate focusTextInput and blurTextInput Closes https://github.com/facebook/react-native/pull/18936 Differential Revision: D8044439 Pulled By: hramos fbshipit-source-id: fde145f04bb1d46ef58b5954cb7963adf495b21c --- Libraries/Components/TextInput/TextInput.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index a9f6716a340f91..7909b5a8fae5b8 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -325,7 +325,23 @@ type Props = $ReadOnly<{| const TextInput = createReactClass({ displayName: 'TextInput', - + statics: { + State: { + currentlyFocusedField: TextInputState.currentlyFocusedField, + focusTextInput: (textFieldID: ?number) => { + console.warn( + '`focusTextInput` is deprecated, use the `focus` method of the `TextInput` ref instead.', + ); + TextInputState.focusTextInput(textFieldID); + }, + blurTextInput: (textFieldID: ?number) => { + console.warn( + '`blurTextInput` is deprecated, use `Keyboard.dismiss` or the `blur` method of the `TextInput` ref.', + ); + TextInputState.blurTextInput(textFieldID); + }, + }, + }, propTypes: { ...ViewPropTypes, /**