remove state.value and rely only on props.value (#2635)
This commit is contained in:
parent
676babf313
commit
e744083833
1 changed files with 2 additions and 16 deletions
|
|
@ -68,22 +68,11 @@ export default class SearchBarAndroid extends PureComponent {
|
|||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
value: props.value,
|
||||
isFocused: false,
|
||||
refocusInput: true,
|
||||
};
|
||||
}
|
||||
|
||||
static getDerivedStateFromProps(nextProps, prevState) {
|
||||
if (nextProps.value !== prevState.value) {
|
||||
return {
|
||||
value: nextProps.value,
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
cancel = () => {
|
||||
this.onCancelButtonPress();
|
||||
};
|
||||
|
|
@ -107,7 +96,6 @@ export default class SearchBarAndroid extends PureComponent {
|
|||
InteractionManager.runAfterInteractions(() => {
|
||||
this.setState({
|
||||
isFocused: false,
|
||||
value: '',
|
||||
}, () => {
|
||||
this.props.onCancelButtonPress();
|
||||
});
|
||||
|
|
@ -119,9 +107,7 @@ export default class SearchBarAndroid extends PureComponent {
|
|||
};
|
||||
|
||||
onChangeText = (value) => {
|
||||
this.setState({value}, () => {
|
||||
this.props.onChangeText(value);
|
||||
});
|
||||
this.props.onChangeText(value);
|
||||
};
|
||||
|
||||
onSelectionChange = (event) => {
|
||||
|
|
@ -219,7 +205,7 @@ export default class SearchBarAndroid extends PureComponent {
|
|||
ref='input'
|
||||
blurOnSubmit={blurOnSubmit}
|
||||
refocusInput={this.state.refocusInput}
|
||||
value={this.state.value}
|
||||
value={this.props.value}
|
||||
autoCapitalize={autoCapitalize}
|
||||
autoCorrect={false}
|
||||
returnKeyType={returnKeyType || 'search'}
|
||||
|
|
|
|||
Loading…
Reference in a new issue