Skip to content

Commit

Permalink
Allowing to pass options to Select.Async to be able to set an initial…
Browse files Browse the repository at this point in the history
… value

#1138
  • Loading branch information
Dennis Stücken committed Sep 8, 2016
1 parent fa569e1 commit 01a7bcc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Async.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const Async = React.createClass({
placeholder: stringOrNode, // field placeholder, displayed when there's no value (shared with Select)
searchPromptText: stringOrNode, // label to prompt for search input
searchingText: React.PropTypes.string, // message to display while options are loading
options: React.PropTypes.array, // initial options, usefull if you want to do a preselection and your minimumInput is > 0
},
getDefaultProps () {
return {
Expand Down Expand Up @@ -86,6 +87,14 @@ const Async = React.createClass({
cache: initCache(nextProps.cache),
});
}

if (nextProps.options !== this.props.options) {
if (nextProps.options && nextProps.options.length > 0) {
this.setState({
options: nextProps.options,
});
}
}
},
focus () {
this.select.focus();
Expand Down

0 comments on commit 01a7bcc

Please sign in to comment.