Last active
October 20, 2018 21:54
-
-
Save ryanbelke/774e58561899bfc2d53686364faa06eb 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
/* /pages/index.js */ | |
import RestaurantList from "../components/RestaurantList"; | |
import React from "react"; | |
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 Index; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment