Created
October 21, 2018 01:27
-
-
Save ryanbelke/5706a9ed490cb05f973646c820ec6134 to your computer and use it in GitHub Desktop.
index.js file for using defaultPage.js
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
/* /pages/index.js */ | |
import RestaurantList from "../components/RestaurantList"; | |
import React from "react"; | |
import defaultPage from "../hocs/defaultPage"; | |
import { | |
Alert, | |
Button, | |
Col, | |
Input, | |
InputGroup, | |
InputGroupAddon, | |
Row | |
} from "reactstrap"; | |
class Index extends React.Component { | |
constructor(props) { | |
super(props); | |
//query state will be passed to RestaurantList for the filter query | |
this.state = { | |
query: "" | |
}; | |
} | |
onChange(e) { | |
//set the state = to the input typed in the search Input Component | |
//this.state.query gets passed into RestaurantList to filter the results | |
this.setState({ query: e.target.value.toLowerCase() }); | |
} | |
render() { | |
return ( | |
<div className="container-fluid"> | |
<Row> | |
<Col> | |
<div className="search"> | |
<InputGroup> | |
<InputGroupAddon addonType="append"> Search </InputGroupAddon> | |
<Input onChange={this.onChange.bind(this)} /> | |
</InputGroup> | |
</div> | |
<RestaurantList search={this.state.query} /> | |
</Col> | |
</Row> | |
<style jsx> | |
{` | |
.search { | |
margin: 20px; | |
width: 500px; | |
} | |
`} | |
</style> | |
</div> | |
); | |
} | |
} | |
export default defaultPage(Index); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment