Skip to content

Instantly share code, notes, and snippets.

@joshmrallen
Last active August 26, 2018 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshmrallen/4b6215fe29e2b8afec013f8b9475828b to your computer and use it in GitHub Desktop.
Save joshmrallen/4b6215fe29e2b8afec013f8b9475828b to your computer and use it in GitHub Desktop.
import React from 'react';
import './App.css';
import BusinessList from './components/BusinessList/BusinessList';
import SearchBar from './components/SearchBar/SearchBar';
import Yelp from './util/Yelp';
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
businesses: []
};
this.searchYelp = this.searchYelp.bind(this);
}
searchYelp(term, location, sortBy) {
Yelp.search(term, location, sortBy).then(businesses => {
this.setState({businesses: businesses});
});//Searching API, receiving response, and updating state with setState (review for documentation for understanding)
//Yay, finally part 4 functionality is here. Hurray for the API!
}//end searchYelp method
render() {
return (
<div className="App">
<h1>ravenous</h1>
<SearchBar searchYelp={this.searchYelp} />
<BusinessList businesses={this.state.businesses} />
</div>
);//end of return statement
}//end of render method
}//end of App class
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment