Skip to content

Instantly share code, notes, and snippets.

@olajohn-ajiboye
Created June 29, 2019 05:52
Show Gist options
  • Save olajohn-ajiboye/0c6f70fbc406a1d7deb298ac1e92ed40 to your computer and use it in GitHub Desktop.
Save olajohn-ajiboye/0c6f70fbc406a1d7deb298ac1e92ed40 to your computer and use it in GitHub Desktop.
Class component
import React, { Component } from 'react'
import RecipeList from './components/RecipeList
export default class test extends Component {
constructor(props) {
super(props)
this.state = {
apiResponse: [],
}
}
componentDidMount() {
fetch(`https://api.myjson.com/bins/t7szj`)
.then(data => data.json)
.then(apiResponse => this.setState({ apiResponse }))
}
render() {
return (
<div>
<RecipeList recipes={this.state.recipes}>
</div>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment