Skip to content

Instantly share code, notes, and snippets.

@olajohn-ajiboye
Created June 29, 2019 06:12
Show Gist options
  • Save olajohn-ajiboye/cee82ece6b79dbd0326db88fbcda996f to your computer and use it in GitHub Desktop.
Save olajohn-ajiboye/cee82ece6b79dbd0326db88fbcda996f to your computer and use it in GitHub Desktop.
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