Created
May 2, 2017 03:54
-
-
Save itsthatguy/e6cf95349ba4daa4b50f8a9e949ae2f5 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
import React, {PureComponent} from 'react'; | |
// I've setup webpack to use relative paths from the src/ directory | |
import Results from 'Results'; | |
import SearchBar from 'SearchBar'; | |
// What is a PureComponent? | |
class Layout extends PureComponent { | |
// constructor receives props | |
// should we explain props? | |
constructor (props) { | |
super(props); | |
// setting initial state in the constructor | |
this.state = {searchTerm: ''}; | |
} | |
handleSearch (event) { | |
console.log('event', event); | |
} | |
render () { | |
return ( | |
<div> | |
{/* | |
- Why do we bind handleSearch? | |
- What does bind do? | |
*/} | |
<SearchBar handleSearch={this.handleSearch.bind(this)} /> | |
<Results searchTerm={this.state.searchTerm} /> | |
</div> | |
); | |
} | |
} | |
export default Layout; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment