1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-14 23:30:05 +02:00
copilot/spikes/fuzzy-search/react-select/src/search.js
2017-01-06 10:56:19 +00:00

49 lines
939 B
JavaScript

const React = require('react');
const Select = require('react-select');
const Search = React.createClass({
getInitialState: function() {
return {
selectValue: ''
}
},
updateValue: function(newValue) {
console.log('State changed to ' + newValue);
this.setState({
selectValue: newValue
});
},
render: function () {
var 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' },
];
return (
<div>
<h1> {this.props.multi ? 'Multi' : 'Single'} Search </h1>
<Select
ref="stateSelect"
className="is-open"
autofocus
options={options}
name="selected-state"
value={this.state.selectValue}
onChange={this.updateValue}
multi={this.props.multi}
/>
</div>
)
}
})
module.exports = Search