Skip to content

Instantly share code, notes, and snippets.

@theory-of-soul
Created May 18, 2020 09:45
Show Gist options
  • Save theory-of-soul/95b9d4beba832e76ff56bb705d952da0 to your computer and use it in GitHub Desktop.
Save theory-of-soul/95b9d4beba832e76ff56bb705d952da0 to your computer and use it in GitHub Desktop.
How to keep options state after losing focus on async-select?
// For keeping optins need to use inner function handleInputChange
<AsyncSelect
ref={selectRef}
onInputChange={(value: string, {action}: InputActionMeta) => {
if (action === 'input-change') setInputValue(value);
}}
inputValue={inputValue}
onFocus={() => {
if (selectRef.current) {
selectRef.current.handleInputChange(inputValue, {action: 'input-change'});
}
}}
cacheOptions
isClearable
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment