changing setTimeout length

This commit is contained in:
Alex Windett 2017-01-06 10:56:19 +00:00
parent bdc7af27de
commit 8d500cd8d3
2 changed files with 23 additions and 27 deletions

View File

@ -1,10 +1,6 @@
const React = require('react'); const React = require('react');
const Select = require('react-select'); const Select = require('react-select');
const { const SelectAsync = Select.Async
Async
} = Select
const SelectAsync = Async
const SearchAsync = React.createClass({ const SearchAsync = React.createClass({
@ -22,36 +18,35 @@ const SearchAsync = React.createClass({
}); });
}, },
render: function () { options: function(input, callback) {
setTimeout(function() {
callback(null, {
options: [
{ value: 'one', label: 'One' },
{ value: 'two', label: 'Two' },
{ value: 'three', label: 'Three' },
{ value: 'four', label: 'Four' },
{ value: 'five', label: 'Five' },
{ value: 'six', label: 'Six' },
],
// CAREFUL! Only set this to true when there are no more options,
// or more specific queries will not be sent to the server.
complete: true
}, 10000);
});
},
const options = function(input, callback) { render: function () {
setTimeout(function() {
callback(null, {
options: [
{ value: 'one', label: 'One' },
{ value: 'two', label: 'Two' },
{ value: 'three', label: 'Three' },
{ value: 'four', label: 'Four' },
{ value: 'five', label: 'Five' },
{ value: 'six', label: 'Six' },
],
// CAREFUL! Only set this to true when there are no more options,
// or more specific queries will not be sent to the server.
complete: true
}, 1000);
});
}
return ( return (
<div> <div>
<h1> Async Search </h1> <h1> Async Search </h1>
<SelectAsync <SelectAsync
ref="stateSelect" ref="stateSelectAsync"
loadOptions={options} loadOptions={this.options}
value={this.state.selectValue} value={this.state.selectValue}
isLoading={true}
onChange={this.updateValue} onChange={this.updateValue}
multi={this.props.multi} multi={true}
/> />
</div> </div>
) )

View File

@ -33,6 +33,7 @@ const Search = React.createClass({
<h1> {this.props.multi ? 'Multi' : 'Single'} Search </h1> <h1> {this.props.multi ? 'Multi' : 'Single'} Search </h1>
<Select <Select
ref="stateSelect" ref="stateSelect"
className="is-open"
autofocus autofocus
options={options} options={options}
name="selected-state" name="selected-state"