question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Async component update options in weird way

See original GitHub issue

onChange method

  onChange(selected) {
    this.setState({ selected });
  }

load more options - data.data contains proper array


  loadOptions(query, callback) {
    Axios.get('/suggestions', { params: { query } })
      .then(({ data }) => ({ options: data.data }))
      .then(suggestions => callback(null, suggestions));
  }

Async component

<Select.Async
            multi
            autoload
            cache={false}
            ignoreAccents={false}
            ignoreCase={false}
            value={selected}
            clearable={false}
            loadOptions={this.loadOptions}
            onChange={this.onChange}
            valueRenderer={d => <SuggestionOption data={d} />}
            optionRenderer={d => <SuggestionOption data={d} />}
          />

I typed first two letters and i’m getting results screen shot 2017-05-06 at 12 01 03

i typed another one and results gone screen shot 2017-05-06 at 12 01 09

moreover sometimes results are not showing at all, even REST api return array with suggestions

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
MartijnHolscommented, Nov 15, 2017

I got it to work with filterOptions={options => options}.

5reactions
brianedelmancommented, Jan 14, 2018

+1 for this still being an issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-Select Async loadOptions is not loading options properly
I try to use SearchableSelect as an independent component, if i need some back-end action to do this function will trigger that accordingly....
Read more >
Configuration options - React Async
Watches this property through componentDidUpdate and re-runs the promiseFn when the value changes, using a simple reference check ( oldValue !== newValue )....
Read more >
How To Handle Async Data Loading, Lazy Loading, and Code ...
When you unmount, the component useEffect updates the variable. The asynchronous function will still resolve, but it won't make any changes to ...
Read more >
Update on Async Rendering – React Blog
Sometimes people use componentWillUpdate out of a misplaced fear that by the time componentDidUpdate fires, it is “too late” to update the state ......
Read more >
Async/Await - Best Practices in Asynchronous Programming
Avoid Async Void; Async All the Way; Configure Context; Know Your Tools ... invoking an event handler that returns a type is very...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found