keep text input above with lots of text keyboard react native code example
Example 1: react native textinput no keyboard
<TouchableWithoutFeedback onPress={Keyboard.dismiss} >
<TextInput />
</TouchableWithoutFeedback>
Example 2: react native autofocus on text input with keyboard display
const [isFocused, setIsFocued] = React.useState(true)
const setFocus = React.useCallback(() => {
setIsFocued(true)
}, [])
const setBlur = React.useCallback(() => {
setIsFocued(false)
}, [])
const navi = useNavigation()
React.useEffect(() => {
navi.addListener('focus', setFocus)
navi.addListener('blur', setBlur)
return () => {
navi.removeListener('focus', setFocus)
navi.removeListener('blur', setBlur)
}
}, [])
return (
<View>
{focused && <TextInput autoFocus />}
</View>
)