-
-
Save olajohn-ajiboye/cee82ece6b79dbd0326db88fbcda996f to your computer and use it in GitHub Desktop.
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, { useState, useEffect } from 'react'; | |
import RecipeList from './components/RecipeList' | |
import RecipeDetails from './components/RecipeDetails' | |
function App() { | |
const url = `https://api.myjson.com/bins/t7szj` | |
const [recipes, setRecipes] = useState([]) | |
const [loading, setLoading] = useState(true) | |
const fetchRecipe = async () => { | |
const recipeData = await fetch(url) | |
const { recipes } = await recipeData.json() | |
setRecipes(recipes) | |
setLoading(false) | |
} | |
useEffect(() => { | |
fetchRecipe() | |
}) | |
return ( | |
<div> | |
{loading ? <h1 className="text-center">...loading</h1> : <RecipeList recipes={recipes} />} | |
<RecipeDetails></RecipeDetails> | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment