diff --git a/HISTORY.md b/HISTORY.md index 054fe95ff0..395cf4941e 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -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) diff --git a/src/Async.js b/src/Async.js index e844ff1507..5ade966ca0 100644 --- a/src/Async.js +++ b/src/Async.js @@ -66,7 +66,7 @@ export default class Async extends Component { this.loadOptions(''); } } - + componentWillUnmount () { this._callback = null; } @@ -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 = { @@ -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); + } } };