diff --git a/src/Async.js b/src/Async.js index de2c8ad9ad..f4dafd19a3 100644 --- a/src/Async.js +++ b/src/Async.js @@ -68,15 +68,12 @@ export default class Async extends Component { } } - componentWillUpdate (nextProps, nextState) { - const propertiesToSync = ['options']; - propertiesToSync.forEach((prop) => { - if (this.props[prop] !== nextProps[prop]) { - this.setState({ - [prop]: nextProps[prop] - }); - } - }); + componentWillReceiveProps(nextProps) { + if (nextProps.options !== this.props.options) { + this.setState({ + options: nextProps.options, + }); + } } clearOptions() { diff --git a/test/Async-test.js b/test/Async-test.js index 8742e315ff..dd5a38fa62 100644 --- a/test/Async-test.js +++ b/test/Async-test.js @@ -447,4 +447,20 @@ describe('Async', () => { expect(input, 'to equal', document.activeElement); }); }); + + + describe('props sync test', () => { + it('should update options on componentWillReceiveProps', () => { + createControl({ + }); + asyncInstance.componentWillReceiveProps({ + options: [{ + label: 'bar', + value: 'foo', + }] + }); + expect(asyncNode.querySelectorAll('[role=option]').length, 'to equal', 1); + expect(asyncNode.querySelector('[role=option]').textContent, 'to equal', 'bar'); + }); + }); });