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 { Platform , TextInput , View , Keyboard } from 'react-native' ;
55import { useFocusEffect } from '@react-navigation/native' ;
@@ -28,6 +28,7 @@ type Props = $ReadOnly<{|
2828
2929 style ?: ViewStyleProp ,
3030 onChangeText : ( value : string ) => void ,
31+ value : string ,
3132 onSubmitEditing : ( ) => Promise < void > ,
3233 enablesReturnKeyAutomatically : boolean ,
3334| } > ;
@@ -76,23 +77,14 @@ function useRn19366Workaround(textInputRef) {
7677}
7778
7879export default function SmartUrlInput ( props : Props ) : Node {
79- const { style, onChangeText, onSubmitEditing, enablesReturnKeyAutomatically } = props ;
80+ const { style, onChangeText, value , onSubmitEditing, enablesReturnKeyAutomatically } = props ;
8081
8182 // We should replace the fixme with
8283 // `React$ElementRef<typeof TextInput>` when we can. Currently, that
8384 // would make `.current` be `any(implicit)`, which we don't want;
8485 // this is probably down to bugs in Flow's special support for React.
8586 const textInputRef = useRef < $FlowFixMe > ( ) ;
8687
87- /**
88- * The actual input string, exactly as entered by the user,
89- * without modifications by autocomplete.
90- *
91- * Prepopulates with "https://", because not everyone has memorized that
92- * sequence of characters.
93- */
94- const [ value , setValue ] = useState < string > ( 'https://' ) ;
95-
9688 const themeContext = useContext ( ThemeContext ) ;
9789
9890 // When the route is focused in the navigation, focus the input.
@@ -107,14 +99,6 @@ export default function SmartUrlInput(props: Props): Node {
10799 } , [ ] ) ,
108100 ) ;
109101
110- const handleChange = useCallback (
111- ( _value : string ) => {
112- setValue ( _value ) ;
113- onChangeText ( _value ) ;
114- } ,
115- [ onChangeText ] ,
116- ) ;
117-
118102 if ( Platform . OS === 'android' ) {
119103 // (This eslint-disable is fine; the relevant rule is not to call Hooks
120104 // conditionally. But this conditional won't vary in its behavior
@@ -132,7 +116,7 @@ export default function SmartUrlInput(props: Props): Node {
132116 autoCorrect = { false }
133117 autoCapitalize = "none"
134118 returnKeyType = "go"
135- onChangeText = { handleChange }
119+ onChangeText = { onChangeText }
136120 blurOnSubmit = { false }
137121 keyboardType = "url"
138122 underlineColorAndroid = "transparent"
0 commit comments