@@ -40,8 +40,8 @@ export default function RealmInputScreen(props: Props): Node {
4040
4141 const [ error , setError ] = useState < string | null > ( null ) ;
4242
43- const tryRealm = useCallback ( async ( ) => {
44- const parsedRealm = urlFromInputValue ( realmInputValue ) ;
43+ const tryRealm = useCallback ( async unparsedUrl => {
44+ const parsedRealm = urlFromInputValue ( unparsedUrl ) ;
4545 if ( ! parsedRealm ) {
4646 setError ( 'Please enter a valid URL' ) ;
4747 return ;
@@ -65,7 +65,11 @@ export default function RealmInputScreen(props: Props): Node {
6565 } finally {
6666 setProgress ( false ) ;
6767 }
68- } , [ realmInputValue ] ) ;
68+ } , [ ] ) ;
69+
70+ const handleInputSubmit = useCallback ( ( ) => {
71+ tryRealm ( realmInputValue ) ;
72+ } , [ tryRealm , realmInputValue ] ) ;
6973
7074 const styles = {
7175 input : { marginTop : 16 , marginBottom : 8 } ,
@@ -88,7 +92,7 @@ export default function RealmInputScreen(props: Props): Node {
8892 navigation = { navigation }
8993 onChangeText = { setRealmInputValue }
9094 value = { realmInputValue }
91- onSubmitEditing = { tryRealm }
95+ onSubmitEditing = { handleInputSubmit }
9296 enablesReturnKeyAutomatically
9397 />
9498 { error !== null ? (
@@ -100,7 +104,7 @@ export default function RealmInputScreen(props: Props): Node {
100104 style = { styles . button }
101105 text = "Enter"
102106 progress = { progress }
103- onPress = { tryRealm }
107+ onPress = { handleInputSubmit }
104108 disabled = { urlFromInputValue ( realmInputValue ) === undefined }
105109 />
106110 </ Screen >
0 commit comments