I try to apply react-select to create async selection like the demo,
And want to add default value for the input.
As below, the default value will be clear when onBlur because onBlur will default trigger handleInputChange event with empty value.
I guess this might case by some default setting like 'onBlurResetsInput',
but 'onBlurResetsInput' props has be removed at v2.0.0.
So want to know how to prevent onBlur reset, thanks.
import Async from 'react-select/lib/Async';
export class AsyncSelect extends React.PureComponent {
state = {
inputValue: this.props.defaultValue,
}
handleInputChange = (value) => {
this.setState({
inputValue: value,
});
this.props.syncOptions(value);
}
render() {
return (
<Async
inputValue={this.state.inputValue}
onInputChange={this.handleInputChange}
options={this.props.options}
onChange={(option) => this.props.selectOption(option.value)}
/>
);
}
}