Skip to content

Commit ce3b7b8

Browse files
janicduplessisfacebook-github-bot
authored andcommitted
Bring back TextInput.State, deprecate focusTextInput and blurTextInput
Summary: a275eac 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 #18936 Differential Revision: D8044439 Pulled By: hramos fbshipit-source-id: fde145f04bb1d46ef58b5954cb7963adf495b21c
1 parent 4e1453e commit ce3b7b8

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Libraries/Components/TextInput/TextInput.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,23 @@ type Props = $ReadOnly<{|
325325

326326
const TextInput = createReactClass({
327327
displayName: 'TextInput',
328-
328+
statics: {
329+
State: {
330+
currentlyFocusedField: TextInputState.currentlyFocusedField,
331+
focusTextInput: (textFieldID: ?number) => {
332+
console.warn(
333+
'`focusTextInput` is deprecated, use the `focus` method of the `TextInput` ref instead.',
334+
);
335+
TextInputState.focusTextInput(textFieldID);
336+
},
337+
blurTextInput: (textFieldID: ?number) => {
338+
console.warn(
339+
'`blurTextInput` is deprecated, use `Keyboard.dismiss` or the `blur` method of the `TextInput` ref.',
340+
);
341+
TextInputState.blurTextInput(textFieldID);
342+
},
343+
},
344+
},
329345
propTypes: {
330346
...ViewPropTypes,
331347
/**

0 commit comments

Comments
 (0)