Skip to content

Instantly share code, notes, and snippets.

@sonthonaxrk
Created July 2, 2015 16:21
Show Gist options
  • Save sonthonaxrk/e36af4e558bf4a2d016d to your computer and use it in GitHub Desktop.
Save sonthonaxrk/e36af4e558bf4a2d016d to your computer and use it in GitHub Desktop.
const Search = React.createClass({
render() {
return (
<div ref="container" className={containerClasses}>
<div id="location_search" className={locationSearchClasses}>
<div className="input-group-element">
<input
onChange={this.onSearch}
value={this.state.searchText}
ref="search"
type="text"
placeholder="Enter your location."/>
</div>
<div className="input-group-element">
<input className="btn-primary" type="button" value="go"/>
</div>
</div>
</div>
);
},
componentWillMount() {
this.onSearch = debounce(this.onSearch, 200);
},
onSearch(e) {
const search = e.target.value;
this.setState({
searching: true,
searchText: search,
selectedIndex: -1
});
requestPlaces(search).then(function (response) {
this.setState({
searching: false,
predictions: response.predictions
});
}.bind(this));
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment