Created
May 18, 2020 09:45
-
-
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?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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