diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index 9b6a0c513c88cd..02e1db674aff5e 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -702,14 +702,25 @@ function useFocusOnMount( // Since initialAutoFocusValue and inputRef will never change // this should match the expected behavior if (initialAutoFocusValue.current) { - const rafId = requestAnimationFrame(() => { + const focus = () => { if (inputRef.current != null) { inputRef.current.focus(); } - }); + }; + + let rafId; + if (Platform.OS === 'android') { + // On Android this needs to be executed in a rAF callback + // otherwise the keyboard opens then closes immediately. + rafId = requestAnimationFrame(focus); + } else { + focus(); + } return () => { - cancelAnimationFrame(rafId); + if (rafId != null) { + cancelAnimationFrame(rafId); + } }; } }, [initialAutoFocusValue, inputRef]);