From 476a831ea09c25d0bbcb97a536c5bef76a1c8273 Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Mon, 6 Aug 2018 14:56:11 -0700 Subject: [PATCH] Un-deprecate TextInput.State.focusTextInput and TextInput.State.blurTextInput (#20326) Summary: In https://github.com/facebook/react-native/pull/18936 we decided to deprecate `focusTextInput` and `blurTextInput` but since then I found a valid use case for it that is pretty much impossible to implement otherwise. React Navigation uses it to blur / re-focus the input during the swipe back gesture. Blur can be done with Keyboard.dismiss but without this api we cannot re-focus the text field that was focused if the swipe back gesture is cancelled. See https://github.com/react-navigation/react-navigation/blob/master/src/navigators/createKeyboardAwareNavigator.js#L21-L34 I think it is best to just bring back this api. Pull Request resolved: https://github.com/facebook/react-native/pull/20326 Differential Revision: D9182810 Pulled By: hramos fbshipit-source-id: 3740421ffafb8f814522d15788f3466324177c16 --- Libraries/Components/TextInput/TextInput.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index 80dcb8ecf182a2..178821b3ad7042 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -326,18 +326,8 @@ const TextInput = createReactClass({ 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); - }, + focusTextInput: TextInputState.focusTextInput, + blurTextInput: TextInputState.blurTextInput, }, }, propTypes: {