Option Does not get rendered without typing white space
See original GitHub issueWhen I try to use async menus are rendered only when I type whitespace. I can verify that it is not problem of loadOptions since I can verify that function call successfully since it is called when I did not make white space at the end of my inputbox.
getAddressOpts = debounce((address) => {
if (!address || address.length < 3) {
return Promise.resolve({ options: [] });
}
let originalUrl= 'api/get_address_info';
originalUrl = originalUrl + "/" + address
return fetch(originalUrl)
.then((response) => response.json())
.catch((error) => {options:[]})
.then((json) => {
return {
options: json.map((data)=>{
var return_data = {}
return_data['value'] = data.address
return_data['label'] = data.address
return return_data
}),
complete: true};})
},800)
<Select.Async name="address" searchPromptText="주소나 지명을 입력해주세요" cache={false} loadingPlaceholder="" isLoading={true} onChange={this.onChange} value={this.state.value} loadOptions={this.getAddressOpts} backspaceRemoves={true} />
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:7
Top Results From Across the Web
white-space - CSS: Cascading Style Sheets - MDN Web Docs
The white-space CSS property sets how white space inside an element is handled.
Read more >Preserving white space in an HTML select option
When creating the select option with javascript, to preserve white-space, use "\xa0" - it is a NO-BREAK SPACE char.
Read more >white-space - CSS-Tricks
The CSS white-space property controls how text is handled on the element it is applied to. Let's say you have HTML exactly like...
Read more >Dealing with significant white space in HTML
CSS: whitespace: no-wrap. The next white space variation is no-wrap . This option will remove all white spaces in the text and newlines....
Read more >Description of the "White space between pages" option in Word
In Microsoft Word, you can hide the white space at the top and bottom of each page and reduce the amount of gray...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @martin-g
Don`t return Promise in debounce.
This not working:
and this is not working:
Working for me:
My guess is that the
loadOptions
function is expected to either return a promise or execute a callback, but your debounced function does neither.It seems that in order to use
_.debounce
, you’ll need to use a callback. Maybe something like this:Also check out https://github.com/JedWatson/react-select/issues/2476 and https://github.com/JedWatson/react-select/issues/614