1 const [isFocused, setIsFocued] = React.useState(true)
2
3 const setFocus = React.useCallback(() => {
4 setIsFocued(true)
5 }, [])
6
7 const setBlur = React.useCallback(() => {
8 setIsFocued(false)
9 }, [])
10
11 const navi = useNavigation()
12
13 React.useEffect(() => {
14 navi.addListener('focus', setFocus)
15 navi.addListener('blur', setBlur)
16 return () => {
17 navi.removeListener('focus', setFocus)
18 navi.removeListener('blur', setBlur)
19 }
20 }, [])
21
22 return (
23 <View>
24 {focused && <TextInput autoFocus />}
25 </View>
26 )