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

Manually set 'isLoading' state for async selects #3690

Merged
merged 2 commits into from
Oct 2, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nine-goats-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-select": minor
---

Add `isLoading` prop support to the AsyncSelect component (see #3690)
6 changes: 4 additions & 2 deletions packages/react-select/src/Async.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type AsyncProps = {
cacheOptions: any,
onInputChange: (string, InputActionMeta) => void,
inputValue?: string,
isLoading: boolean
};

export type Props = SelectProps & AsyncProps;
Expand All @@ -31,6 +32,7 @@ export const defaultProps = {
cacheOptions: false,
defaultOptions: false,
filterOption: null,
isLoading: false
};

type State = {
Expand Down Expand Up @@ -158,7 +160,7 @@ export const makeAsyncSelect = <C: {}>(
return inputValue;
};
render() {
const { loadOptions, ...props } = this.props;
const { loadOptions, isLoading: isLoadingProp, ...props } = this.props;
const {
defaultOptions,
inputValue,
Expand All @@ -179,7 +181,7 @@ export const makeAsyncSelect = <C: {}>(
this.select = ref;
}}
options={options}
isLoading={isLoading}
isLoading={isLoading || isLoadingProp}
onInputChange={this.handleInputChange}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ exports[`defaults - snapshot 1`] = `
cacheOptions={false}
defaultOptions={false}
filterOption={null}
isLoading={false}
>
<StateManager
cacheOptions={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ exports[`defaults - snapshot 1`] = `
cacheOptions={false}
defaultOptions={false}
filterOption={null}
isLoading={false}
>
<StateManager
cacheOptions={false}
Expand Down