-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c17627c
commit 79cf3a3
Showing
4 changed files
with
24 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,24 @@ | ||
"use client" | ||
|
||
import React, { useEffect, useState } from 'react'; | ||
import RecipeCards from './RecipeCards'; | ||
import SkeletonGrid from './SkeletonMain'; | ||
|
||
const RecipeGrid = () => { | ||
const [recipes, setRecipes] = useState([]); | ||
|
||
useEffect(() => { | ||
const fetchRecipes = async () => { | ||
try { | ||
const response = await fetch('https://dummyjson.com/recipes'); | ||
const data = await response.json(); | ||
setRecipes(data.recipes); | ||
} catch (error) { | ||
console.error('Error fetching recipes:', error); | ||
} | ||
}; | ||
|
||
fetchRecipes(); | ||
}, []); | ||
// This is now a server component | ||
const RecipeGrid = async () => { | ||
|
||
// Fetch recipes directly from the server | ||
const response = await fetch('https://dummyjson.com/recipes',{cache:'no-store'}); | ||
const data = await response.json(); | ||
|
||
// Assuming data.recipes contains an array of recipes | ||
const recipes = data.recipes; | ||
|
||
return ( | ||
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-6 p-6"> | ||
{recipes.map(recipe => ( | ||
{recipes.map((recipe) => ( | ||
<RecipeCards key={recipe.id} recipe={recipe} /> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default RecipeGrid; | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,7 @@ export default function RootLayout({ children }) { | |
</html> | ||
); | ||
} | ||
|
||
|
||
|
||
|
This file contains 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