From 44deec60d267b52ea6d2e1fcce1054380724bc5e Mon Sep 17 00:00:00 2001 From: Patrik Matous Date: Wed, 21 Sep 2016 13:51:50 +0200 Subject: [PATCH] Fixed delayed value --- src/typeahead/index.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/typeahead/index.js b/src/typeahead/index.js index 5a2b72bc..2a8b8fbf 100644 --- a/src/typeahead/index.js +++ b/src/typeahead/index.js @@ -307,9 +307,16 @@ var Typeahead = React.createClass({ }, componentWillReceiveProps: function(nextProps) { - this.setState({ - searchResults: this.getOptionsForValue(this.state.entryValue, nextProps.options) - }); + if (this.state.entryValue !== nextProps.value) { + this.setState({ + entryValue: nextProps.value, + searchResults: this.getOptionsForValue(nextProps.value, nextProps.options) + }); + } else { + this.setState({ + searchResults: this.getOptionsForValue(this.state.entryValue, nextProps.options) + }); + } }, render: function() {