JedWatson / JedWatson/react-select

Added isMulti on AsyncSelect and Async (loadOptions) doesn't work

Open
#5,473 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

awaiting-author-response issue/bug-unconfirmed
Dominant language
TypeScript
Stars
28k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

Hi,

First : thank you so much for this package!

When I added isMulti on the AsyncSelect, I don't see the different options loaded, always empty:

import AsyncSelect from 'react-select/async';

...

const loadOptions = async (inputValue, callback) => {
    let data = await axios.get(route('dashboard.tags.searchTag'), { params: { name: inputValue } }).then((response) => {
        const options = [];

        response.data.data.forEach((item) => {
            options.push(item);
        });

        return options;
    });

    callback(data);
};

...

<AsyncSelect
    isMulti
    value={post.tags}
    onChange={handleChange}
    loadOptions={loadOptions}
    getOptionLabel={(option) => option.name}
/>

Without isMulti on AsyncSelect, I see the different options:

Capture d’écran 2022-11-08 à 21 32 49

I used "react-select": "^5.6.0"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the AsyncSelect entry point and reproduce the reported example with isMulti, value, loadOptions, and getOptionLabel. Compare the behavior with and without isMulti using the supplied loadOptions implementation. Done means the asynchronously loaded options appear when isMulti is enabled as well as when it is omitted.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.