Skip to content

Commit

Permalink
Check before calling onChange, fixes JedWatson#1988
Browse files Browse the repository at this point in the history
  • Loading branch information
JedWatson committed Sep 12, 2017
1 parent bf343fe commit 6a7778f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# React-Select

## Unreleased

* fixed; `Async` component always called `onChange` even when it wasn't provided

## v1.0.0-rc.8 / 2017-09-12

* fixed; `onMenuScrollToBottom` does not work in chrome 58.0, thanks [Simon Hartcher](https://github.com/deevus)
Expand Down
8 changes: 5 additions & 3 deletions src/Async.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default class Async extends Component {
this.loadOptions('');
}
}

componentWillUnmount () {
this._callback = null;
}
Expand Down Expand Up @@ -185,7 +185,7 @@ export default class Async extends Component {
}

render () {
const { children, loadingPlaceholder, placeholder } = this.props;
const { children, loadingPlaceholder, onChange, placeholder } = this.props;
const { isLoading, options } = this.state;

const props = {
Expand All @@ -197,7 +197,9 @@ export default class Async extends Component {
if (this.props.multi && this.props.value && (newValues.length > this.props.value.length)) {
this.clearOptions();
}
this.props.onChange(newValues);
if (typeof onChange === 'function') {
onChange(newValues);
}
}
};

Expand Down

0 comments on commit 6a7778f

Please sign in to comment.