Skip to content

Instantly share code, notes, and snippets.

@iwilsonq
Created February 23, 2018 23:05
Show Gist options
  • Save iwilsonq/5eb16fc25dd4cad54d559957851e5da1 to your computer and use it in GitHub Desktop.
Save iwilsonq/5eb16fc25dd4cad54d559957851e5da1 to your computer and use it in GitHub Desktop.
/* ... */
import YelpService from './app/services/yelp'
export default App extends Component {
/* ... */
getCoffeeShops = async () => {
const { latitude, longitude } = this.state.region;
const userLocation = { latitude, longitude };
const coffeeShops = await YelpService.getCoffeeShops(userLocation);
this.setState({ coffeeShops });
};
getLocationAsync = async () => {
/* ... */
// Add this line!
await this.getCoffeeShops();
}
render() {
const { region, coffeeShops } = this.state;
return (
<SafeAreaView style={styles.container}>
<Map region={region} places={coffeeShops} />
</SafeAreaView>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment