-
-
Save olajohn-ajiboye/0c6f70fbc406a1d7deb298ac1e92ed40 to your computer and use it in GitHub Desktop.
Class component
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, { 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