Skip to content

Commit 00a87d7

Browse files
committed
types: Use a React$ElementRef type for React.createRef type parameter.
As Greg pointed out it should be, a few months ago, after some careful examination [1]. Since the `$FlowFixMe`s start getting flagged as "unused suppression comments", remove them. Strangely, `this.textInputRef.current` and friends are `any(implicit)` after this. Hmm. Still, at least we can now say we're doing the `React$ElementRef` part correctly. [1] zulip#4278 (comment)
1 parent e221fc1 commit 00a87d7

File tree

3 files changed

+5
-21
lines changed

3 files changed

+5
-21
lines changed

src/common/InputWithClearButton.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default class InputWithClearButton extends PureComponent<Props, State> {
3232
canBeCleared: false,
3333
text: '',
3434
};
35-
textInputRef = React.createRef<typeof TextInput>();
35+
textInputRef = React.createRef<React$ElementRef<typeof TextInput>>();
3636

3737
handleChangeText = (text: string) => {
3838
this.setState({
@@ -47,9 +47,6 @@ export default class InputWithClearButton extends PureComponent<Props, State> {
4747
handleClear = () => {
4848
this.handleChangeText('');
4949
if (this.textInputRef.current) {
50-
// Should be fixed in RN v0.63 (#4245); see
51-
// https://github.com/zulip/zulip-mobile/issues/4245#issuecomment-695104351.
52-
// $FlowFixMe
5350
this.textInputRef.current.clear();
5451
}
5552
};

src/common/SmartUrlInput.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,12 @@ export default class SmartUrlInput extends PureComponent<Props, State> {
6969
state = {
7070
value: '',
7171
};
72-
textInputRef = React.createRef<typeof TextInput>();
72+
textInputRef = React.createRef<React$ElementRef<typeof TextInput>>();
7373
unsubscribeFocusListener: () => void;
7474

7575
componentDidMount() {
7676
this.unsubscribeFocusListener = this.props.navigation.addListener('focus', () => {
7777
if (this.textInputRef.current) {
78-
// Should be fixed in RN v0.63 (#4245); see
79-
// https://github.com/zulip/zulip-mobile/issues/4245#issuecomment-695104351.
80-
// $FlowFixMe
8178
this.textInputRef.current.focus();
8279
}
8380
});
@@ -99,13 +96,9 @@ export default class SmartUrlInput extends PureComponent<Props, State> {
9996
urlPress = () => {
10097
const { textInputRef } = this;
10198
if (textInputRef.current) {
102-
// Should be fixed in RN v0.63 (#4245); see
103-
// https://github.com/zulip/zulip-mobile/issues/4245#issuecomment-695104351.
104-
// $FlowFixMe
10599
textInputRef.current.blur();
106100
setTimeout(() => {
107101
if (textInputRef.current) {
108-
// $FlowFixMe - same as above
109102
textInputRef.current.focus();
110103
}
111104
}, 100);

src/compose/ComposeBox.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ class ComposeBox extends PureComponent<Props, State> {
129129
static contextType = ThemeContext;
130130
context: ThemeData;
131131

132-
messageInputRef = React.createRef<typeof TextInput>();
133-
topicInputRef = React.createRef<typeof TextInput>();
132+
messageInputRef = React.createRef<React$ElementRef<typeof TextInput>>();
133+
topicInputRef = React.createRef<React$ElementRef<typeof TextInput>>();
134134

135135
// TODO: Type-check this, once we've adjusted our `react-redux`
136136
// wrapper to do the right thing. It should be
137137
//
138-
// mentionWarnings = React.createRef<typeof MentionWarnings>()
138+
// mentionWarnings = React.createRef<React$ElementRef<MentionWarnings>>()
139139
//
140140
// but we need our `react-redux` wrapper to be aware of
141141
// `{ forwardRef: true }`, since we use that.
@@ -348,9 +348,6 @@ class ComposeBox extends PureComponent<Props, State> {
348348
}
349349
completeEditMessage();
350350
if (this.messageInputRef.current !== null) {
351-
// Should be fixed in RN v0.63 (#4245); see
352-
// https://github.com/zulip/zulip-mobile/issues/4245#issuecomment-695104351.
353-
// $FlowFixMe
354351
this.messageInputRef.current.blur();
355352
}
356353
};
@@ -365,9 +362,6 @@ class ComposeBox extends PureComponent<Props, State> {
365362
this.setMessageInputValue(message);
366363
this.setTopicInputValue(topic);
367364
if (this.messageInputRef.current !== null) {
368-
// Should be fixed in RN v0.63 (#4245); see
369-
// https://github.com/zulip/zulip-mobile/issues/4245#issuecomment-695104351.
370-
// $FlowFixMe
371365
this.messageInputRef.current.focus();
372366
}
373367
}

0 commit comments

Comments
 (0)