11/* @flow strict-local */
2- import React , { useState , useRef , useCallback , useContext } from 'react' ;
2+ import React , { useRef , useCallback , useContext } from 'react' ;
33import type { Node } from 'react' ;
44import { TextInput , View } from 'react-native' ;
55import { useFocusEffect } from '@react-navigation/native' ;
@@ -28,21 +28,20 @@ type Props = $ReadOnly<{|
2828
2929 style ?: ViewStyleProp ,
3030 onChangeText : ( value : string ) => void ,
31+ value : string ,
3132 onSubmitEditing : ( ) => Promise < void > ,
3233 enablesReturnKeyAutomatically : boolean ,
3334| } > ;
3435
3536export default function SmartUrlInput ( props : Props ) : Node {
36- const { style, onChangeText, onSubmitEditing, enablesReturnKeyAutomatically } = props ;
37+ const { style, onChangeText, value , onSubmitEditing, enablesReturnKeyAutomatically } = props ;
3738
3839 // We should replace the fixme with
3940 // `React$ElementRef<typeof TextInput>` when we can. Currently, that
4041 // would make `.current` be `any(implicit)`, which we don't want;
4142 // this is probably down to bugs in Flow's special support for React.
4243 const textInputRef = useRef < $FlowFixMe > ( ) ;
4344
44- const [ value , setValue ] = useState < string > ( '' ) ;
45-
4645 const themeContext = useContext ( ThemeContext ) ;
4746
4847 // When the route is focused in the navigation, focus the input.
@@ -65,14 +64,6 @@ export default function SmartUrlInput(props: Props): Node {
6564 } , [ ] ) ,
6665 ) ;
6766
68- const handleChange = useCallback (
69- ( _value : string ) => {
70- setValue ( _value ) ;
71- onChangeText ( _value ) ;
72- } ,
73- [ defaultDomain , defaultProtocol , onChangeText ] ,
74- ) ;
75-
7667 return (
7768 < View style = { [ styles . wrapper , style ] } >
7869 < TextInput
@@ -84,7 +75,7 @@ export default function SmartUrlInput(props: Props): Node {
8475 autoCorrect = { false }
8576 autoCapitalize = "none"
8677 returnKeyType = "go"
87- onChangeText = { handleChange }
78+ onChangeText = { onChangeText }
8879 blurOnSubmit = { false }
8980 keyboardType = "url"
9081 underlineColorAndroid = "transparent"
0 commit comments