Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify the two platform's ComposeBox code #3095

Merged
merged 3 commits into from
Nov 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/common/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type Props = {
style?: Style,
placeholder: LocalizableText,
onChangeText: (text: string) => void,
textInputRef: (component: any) => void,
textInputRef: (component: ?TextInput) => void,
};

type State = {
Expand All @@ -36,7 +36,7 @@ export default class Input extends PureComponent<Props, State> {
state: State = {
isFocused: false,
};
textInput: TextInput;
textInput: ?TextInput;

static contextTypes = {
styles: () => null,
Expand All @@ -54,7 +54,9 @@ export default class Input extends PureComponent<Props, State> {
if (onChangeText) {
onChangeText('');
}
this.textInput.clear();
if (this.textInput) {
this.textInput.clear();
}
};

handleFocus = () => {
Expand Down Expand Up @@ -89,7 +91,7 @@ export default class Input extends PureComponent<Props, State> {
underlineColorAndroid={isFocused ? BORDER_COLOR : HALF_COLOR}
onFocus={this.handleFocus}
onBlur={this.handleBlur}
ref={(component: any) => {
ref={(component: ?TextInput) => {
this.textInput = component;
if (textInputRef) {
textInputRef(component);
Expand Down
6 changes: 4 additions & 2 deletions src/common/InputWithClearButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class InputWithClearButton extends PureComponent<Props, State> {
canBeCleared: false,
text: '',
};
textInput: TextInput;
textInput: ?TextInput;

static contextTypes = {
styles: () => null,
Expand All @@ -54,7 +54,9 @@ export default class InputWithClearButton extends PureComponent<Props, State> {

handleClear = () => {
this.handleChangeText('');
this.textInput.clear();
if (this.textInput) {
this.textInput.clear();
}
};

render() {
Expand Down
4 changes: 1 addition & 3 deletions src/common/MultilineInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Props = {
onBlur?: () => void,
onFocus?: () => void,
onSelectionChange?: (event: Object) => void,
textInputRef?: (component: any) => void,
textInputRef?: (component: ?TextInput) => void,
};

/**
Expand All @@ -37,8 +37,6 @@ export default class MultilineInput extends PureComponent<Props> {
placeholder: {},
};

textInput: TextInput;

render() {
const { onChange, ...restProps } = this.props;

Expand Down
Loading