Skip to content

Commit 9548970

Browse files
committed
RealmInputScreen [nfc]: Have tryRealm take an arg for what realm to try
1 parent 4452fad commit 9548970

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/common/SmartUrlInput.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type Props = $ReadOnly<{|
2929
style?: ViewStyleProp,
3030
onChangeText: (value: string) => void,
3131
value: string,
32-
onSubmitEditing: () => Promise<void>,
32+
onSubmitEditing: () => void,
3333
enablesReturnKeyAutomatically: boolean,
3434
|}>;
3535

src/start/RealmInputScreen.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)