Cache options is not working with AsyncSelect
I'm trying to use Asyncselect with cache options. What I'm trying to do is when a user gives a input, I want to persist that input as well as the options. I'm loading options via loadOptions prop which is calling an API. But what is happing is when a user selects an option the options are dissapearing. I don't know if its a bug or a feature request but can you guys look into this. Thanks! Here's the sandbox link.
Hello @yashjais18,
the onInputChange prop has the ability to return the current inputValue. This is mainly used for uncontrolled scenarios. But the Async component uses that returned value to determine if it should reset among other things the loaded options. This reset is triggered by either returning nothing or returning a non-truthy value.
So instead of returning false on selecting the option you should instead return the current value for inputValue.
Hey. I resolved the issue I was having. So we needed to store the data which we're returning from API. And then we needed to give it as default options. So now the dropdown will also persist options. And thanks for the fast reply! Also one more thing. I was returning from function(which is passed ot loadOptions) like this, that's why It wasn't work for me initially:- this.setState({data: response.data}, () => return data); We need to set the state and return data separately, like this:- this.setState({data: response.data}); return data;
i94furi9efurehfguhrtgv
refgewrgergerfv