Skip to content

Commit e2854d1

Browse files
committed
SmartUrlInput [nfc]: Use React.useMemo for styles
1 parent 5ab469d commit e2854d1

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

src/common/SmartUrlInput.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,6 @@ import { useFocusEffect } from '@react-navigation/native';
66

77
import { ThemeContext, createStyleSheet, HALF_COLOR } from '../styles';
88

9-
const styles = createStyleSheet({
10-
wrapper: {
11-
flexDirection: 'row',
12-
opacity: 0.8,
13-
marginTop: 16,
14-
marginBottom: 8,
15-
},
16-
realmInput: {
17-
flex: 1,
18-
padding: 0,
19-
fontSize: 20,
20-
},
21-
});
22-
239
type Props = $ReadOnly<{|
2410
onChangeText: (value: string) => void,
2511
value: string,
@@ -51,13 +37,32 @@ export default function SmartUrlInput(props: Props): Node {
5137
}, []),
5238
);
5339

40+
const styles = React.useMemo(
41+
() =>
42+
createStyleSheet({
43+
wrapper: {
44+
flexDirection: 'row',
45+
opacity: 0.8,
46+
marginTop: 16,
47+
marginBottom: 8,
48+
},
49+
realmInput: {
50+
flex: 1,
51+
padding: 0,
52+
fontSize: 20,
53+
color: themeContext.color,
54+
},
55+
}),
56+
[themeContext],
57+
);
58+
5459
return (
5560
<View style={styles.wrapper}>
5661
<TextInput
5762
value={value}
5863
placeholder="your-org.zulipchat.com"
5964
placeholderTextColor={HALF_COLOR}
60-
style={[styles.realmInput, { color: themeContext.color }]}
65+
style={styles.realmInput}
6166
autoFocus
6267
autoCorrect={false}
6368
autoCapitalize="none"

0 commit comments

Comments
 (0)