Skip to content

Commit 87d4cf4

Browse files
committed
RealmInputScreen [nfc]: Have tryRealm take an arg for what realm to try
1 parent 50b5a5a commit 87d4cf4

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
@@ -32,8 +32,8 @@ export default function RealmInputScreen(props: Props): Node {
3232

3333
const [error, setError] = useState<string | null>(null);
3434

35-
const tryRealm = useCallback(async () => {
36-
const parsedRealm = tryParseUrl(realmInputValue);
35+
const tryRealm = useCallback(async (unparsedUrl: string) => {
36+
const parsedRealm = tryParseUrl(unparsedUrl);
3737
if (!parsedRealm) {
3838
setError('Please enter a valid URL');
3939
return;
@@ -57,7 +57,11 @@ export default function RealmInputScreen(props: Props): Node {
5757
} finally {
5858
setProgress(false);
5959
}
60-
}, [realmInputValue]);
60+
}, []);
61+
62+
const handleInputSubmit = useCallback(() => {
63+
tryRealm(realmInputValue);
64+
}, [tryRealm, realmInputValue]);
6165

6266
const styles = {
6367
input: { marginTop: 16, marginBottom: 8 },
@@ -80,7 +84,7 @@ export default function RealmInputScreen(props: Props): Node {
8084
navigation={navigation}
8185
onChangeText={setRealmInputValue}
8286
value={realmInputValue}
83-
onSubmitEditing={tryRealm}
87+
onSubmitEditing={handleInputSubmit}
8488
enablesReturnKeyAutomatically
8589
/>
8690
{error !== null ? (
@@ -92,7 +96,7 @@ export default function RealmInputScreen(props: Props): Node {
9296
style={styles.button}
9397
text="Enter"
9498
progress={progress}
95-
onPress={tryRealm}
99+
onPress={handleInputSubmit}
96100
disabled={tryParseUrl(realmInputValue) === undefined}
97101
/>
98102
</Screen>

0 commit comments

Comments
 (0)