Skip to content

Instantly share code, notes, and snippets.

@itsthatguy
Created May 2, 2017 03:54
Show Gist options
  • Save itsthatguy/e6cf95349ba4daa4b50f8a9e949ae2f5 to your computer and use it in GitHub Desktop.
Save itsthatguy/e6cf95349ba4daa4b50f8a9e949ae2f5 to your computer and use it in GitHub Desktop.
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