11/* @flow strict-local */
2- import React , { useState , useCallback , useContext } from 'react' ;
2+ import React , { useCallback , useContext } from 'react' ;
33import type { Node } from 'react' ;
44import { TextInput , View } from 'react-native' ;
55import { useFocusEffect } from '@react-navigation/native' ;
@@ -22,16 +22,15 @@ const styles = createStyleSheet({
2222
2323type Props = $ReadOnly < { |
2424 onChangeText : ( value : string ) => void ,
25+ value : string ,
2526 onSubmitEditing : ( ) => Promise < void > ,
2627| } > ;
2728
2829export default function SmartUrlInput ( props : Props ) : Node {
29- const { onChangeText, onSubmitEditing } = props ;
30+ const { onChangeText, value , onSubmitEditing } = props ;
3031
3132 const textInputRef = React . useRef < React$ElementRef < typeof TextInput > | null > ( null ) ;
3233
33- const [ value , setValue ] = useState < string > ( '' ) ;
34-
3534 const themeContext = useContext ( ThemeContext ) ;
3635
3736 // When the route is focused in the navigation, focus the input.
@@ -52,14 +51,6 @@ export default function SmartUrlInput(props: Props): Node {
5251 } , [ ] ) ,
5352 ) ;
5453
55- const handleChange = useCallback (
56- ( _value : string ) => {
57- setValue ( _value ) ;
58- onChangeText ( _value ) ;
59- } ,
60- [ onChangeText ] ,
61- ) ;
62-
6354 return (
6455 < View style = { styles . wrapper } >
6556 < TextInput
@@ -71,7 +62,7 @@ export default function SmartUrlInput(props: Props): Node {
7162 autoCorrect = { false }
7263 autoCapitalize = "none"
7364 returnKeyType = "go"
74- onChangeText = { handleChange }
65+ onChangeText = { onChangeText }
7566 blurOnSubmit = { false }
7667 keyboardType = "url"
7768 underlineColorAndroid = "transparent"
0 commit comments