1
1
/* @flow strict-local */
2
- import React , { useState , useCallback , useContext } from 'react' ;
2
+ import React , { useCallback , useContext } from 'react' ;
3
3
import type { Node } from 'react' ;
4
4
import { TextInput , View } from 'react-native' ;
5
5
import { useFocusEffect } from '@react-navigation/native' ;
@@ -22,16 +22,15 @@ const styles = createStyleSheet({
22
22
23
23
type Props = $ReadOnly < { |
24
24
onChangeText : ( value : string ) => void ,
25
+ value : string ,
25
26
onSubmitEditing : ( ) => Promise < void > ,
26
27
| } > ;
27
28
28
29
export default function SmartUrlInput ( props : Props ) : Node {
29
- const { onChangeText, onSubmitEditing } = props ;
30
+ const { onChangeText, value , onSubmitEditing } = props ;
30
31
31
32
const textInputRef = React . useRef < React$ElementRef < typeof TextInput > | null > ( null ) ;
32
33
33
- const [ value , setValue ] = useState < string > ( '' ) ;
34
-
35
34
const themeContext = useContext ( ThemeContext ) ;
36
35
37
36
// When the route is focused in the navigation, focus the input.
@@ -52,14 +51,6 @@ export default function SmartUrlInput(props: Props): Node {
52
51
} , [ ] ) ,
53
52
) ;
54
53
55
- const handleChange = useCallback (
56
- ( _value : string ) => {
57
- setValue ( _value ) ;
58
- onChangeText ( _value ) ;
59
- } ,
60
- [ onChangeText ] ,
61
- ) ;
62
-
63
54
return (
64
55
< View style = { styles . wrapper } >
65
56
< TextInput
@@ -71,7 +62,7 @@ export default function SmartUrlInput(props: Props): Node {
71
62
autoCorrect = { false }
72
63
autoCapitalize = "none"
73
64
returnKeyType = "go"
74
- onChangeText = { handleChange }
65
+ onChangeText = { onChangeText }
75
66
blurOnSubmit = { false }
76
67
keyboardType = "url"
77
68
underlineColorAndroid = "transparent"
0 commit comments