const Recipes = () => {
const [recipesList, setRecipesList] = useState([])
const url = "recipeapi.com/blabla";
useEffect(() => {
fetch(url)
.then((resp) => resp.json())
.then((data) => setRecipesList(data))
.catch((err) => console.log(err));
}, []);
if (recipesList.length !== 0) {
return(
<div className="recipes">
<div>
{recipesList ? <Recipe className="recipe" info={recipesList}/> : null }
</div>
</div>
)
}
else {
return(
<h1>Loading</h1>
)
}
}
export default Recipes;
This is my code, I am trying to fetch the recipe data from the api, but I am stuck with this rerendering error. I have no clue why it occurs.