Skip to content

Commit 5af4f8d

Browse files
chrisbobbegnprice
authored andcommitted
RealmInputScreen [nfc]: Pull out parsedRealm to component toplevel
1 parent 86f2829 commit 5af4f8d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/start/RealmInputScreen.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export default function RealmInputScreen(props: Props): Node {
3636

3737
const [progress, setProgress] = React.useState(false);
3838
const [realmInputValue, setRealmInputValue] = React.useState('');
39+
const parsedRealm = urlFromInputValue(realmInputValue);
3940
const [error, setError] = React.useState(null);
4041

4142
const textInputRef = React.useRef<React$ElementRef<typeof TextInput> | null>(null);
@@ -59,7 +60,6 @@ export default function RealmInputScreen(props: Props): Node {
5960
);
6061

6162
const tryRealm = React.useCallback(async () => {
62-
const parsedRealm = urlFromInputValue(realmInputValue);
6363
if (!parsedRealm) {
6464
setError('Please enter a valid URL.');
6565
return;
@@ -85,7 +85,7 @@ export default function RealmInputScreen(props: Props): Node {
8585
} finally {
8686
setProgress(false);
8787
}
88-
}, [navigation, realmInputValue]);
88+
}, [navigation, parsedRealm]);
8989

9090
const styles = React.useMemo(
9191
() =>
@@ -148,7 +148,7 @@ export default function RealmInputScreen(props: Props): Node {
148148
text="Enter"
149149
progress={progress}
150150
onPress={tryRealm}
151-
disabled={urlFromInputValue(realmInputValue) === undefined}
151+
disabled={parsedRealm === undefined}
152152
/>
153153
</Screen>
154154
);

0 commit comments

Comments
 (0)