Created
July 2, 2015 16:21
-
-
Save sonthonaxrk/e36af4e558bf4a2d016d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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