Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import React, {PropTypes} from 'react'
  2. import Geosuggest from 'react-geosuggest'
  3. import onClickOutside from 'react-onclickoutside'
  4.  
  5. class SearchBox extends React.Component {
  6. constructor(props) {
  7. super(props);
  8. this.state = {
  9. isSearchVisible: false
  10. }
  11. }
  12. handleClickOutside() {
  13. this.setState({isSearchVisible: false});
  14. }
  15.  
  16. render() {
  17. return (<div id="searchBox" className={(this.state.isSearchVisible && 'active') + ' floatItem'}>
  18. <i onClick={() => {this.setState({isSearchVisible: !this.state.isSearchVisible})}} className="fa fa-search"></i>
  19. <span>
  20. <Geosuggest onSuggestSelect={this.props.onLocationPicked} className="geoLocation"/>
  21. </span>
  22. </div>);
  23. }
  24. }
  25.  
  26. SearchBox.propTypes = {
  27. onLocationPicked: React.PropTypes.func
  28. };
  29.  
  30. export default onClickOutside(SearchBox)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement