Skip to content

Commit

Permalink
Merge pull request #3690 from csilkwor/Async_isLoading_fix
Browse files Browse the repository at this point in the history
Manually set 'isLoading' state for async selects
  • Loading branch information
JedWatson authored Oct 2, 2019
2 parents 7aae174 + 4cf6c43 commit 8f48d9f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
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

0 comments on commit 8f48d9f

Please sign in to comment.