Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type inference for Async's loadOptions prop #5082

Merged
merged 2 commits into from Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/serious-cheetahs-give.md
@@ -0,0 +1,5 @@
---
'react-select': patch
---

Fix type inference for Async's loadOptions prop
10 changes: 4 additions & 6 deletions packages/react-select/src/useAsync.ts
Expand Up @@ -24,12 +24,10 @@ export interface AsyncAdditionalProps<Option, Group extends GroupBase<Option>> {
* Function that returns a promise, which is the set of options to be used
* once the promise resolves.
*/
loadOptions?:
| ((
inputValue: string,
callback: (options: OptionsOrGroups<Option, Group>) => void
) => void)
| ((inputValue: string) => Promise<OptionsOrGroups<Option, Group>>);
loadOptions?: (
inputValue: string,
callback: (options: OptionsOrGroups<Option, Group>) => void
) => Promise<OptionsOrGroups<Option, Group>> | void;
/**
* Will cause the select to be displayed in the loading state, even if the
* Async select is not currently waiting for loadOptions to resolve
Expand Down