Select.Async isn't using the options passed
See original GitHub issueI can’t have an actual example because the API I’m using isn’t public, but I’ve simplified the code as much as I could.
Basically, the options I pass to the getOptions
callback isn’t always showing properly in the select. My api returns a maximum of 5 items, e.g:
Pitt st
would render 5 items in the selectPitt st ma
would render 1 items in the select even though the console.log before the callback has 5 items. To properly show those items, I have to close the dropdown and open it again. I tried withcache={false}
&complete: false/true
(yeah, both) and every possible combination but it didn’t change anything.
Am I doing anything wrong or it’s expected since it’s in rc ?
Cheers
import React, { Component, PropTypes } from 'react'
import Select from 'react-select'
let timeout
const getOptions = (text, cb) => {
if (text.length <= 3) return cb()
if (timeout) clearTimeout(timeout)
timeout = setTimeout(() => {
fetch(`api/${text}.json`)
.then((res) => res.json())
.then((data) => {
const options = data.map((d) => ({
value: d,
label: d.label,
}))
console.log(options)
cb(null, { options })
})
}, 500)
}
export default ({ value, onChange }) => (
<Select.Async
value={value}
loadOptions={this.getOptions}
onChange={onChange()}
/>
)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
React-select/async not showing options to filter - Stack Overflow
AsyncSelect is a react library that you can use to select a specific value from the database its a select option HTML but...
Read more >Async Data Fetching with React-Select - OpenReplay Blog
With it, we will demonstrate different select options such as singe, multi-search, and creatable search in which users can create ...
Read more >API - React Select
A flexible and beautiful Select Input control for ReactJS with multiselect, autocomplete and ajax support.
Read more >How to Asynchronously Populate List Options in the ... - Sanity.io
Let's use our schema's options to pass in a url and a handler , as well as change some of the names of...
Read more >Asyncify — Emscripten 3.1.26-git (dev) documentation
Asyncify lets synchronous C or C++ code interact with asynchronous JavaScript. ... use the Module.ccall function and pass async: true to its call...
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
Ah. If you just want to disable filtering and let the Api handle it- then just provide your own
filterOptions
function that returns the fulloptions
array every time. 😄I forgot to add
cb
when I simplified the example, but I do have it in my actual code.Here’s screenshots of the weird behavior I’m experiencing: