Dummyjson posts

This commit is contained in:
Kovács Rudolf committed 2026-10-08 11:05:18 +02:00
1 parent 5f6df55a82
commit aa9de8b37c
20 files changed
+3395

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
function Header({szoveg}) {
return (
<h1 className="text-3xl text-center font-bold text-cyan-900 bg-cyan-300">{szoveg}</h1>
)
}
export default Header
+29
View File
@@ -0,0 +1,29 @@
function Post({ post }) {
return (
<div className="card bg-cyan-300 m-2 shadow-sm">
<div className="card-body">
<h2 className="card-title">
{post.title}
</h2>
<div className="card-actions justify-start">
{
post.tags.map((tag,i)=>(<div key={i} className="badge badge-secondary">{tag}</div>))
}
</div>
<p>{post.body}</p>
<div className="card-actions justify-end">
<div className="badge badge-outline">&#x1F44D;{post.reactions.likes}</div>
<div className="badge badge-outline">&#x1F44E; {post.reactions.dislikes}</div>
<div className="badge badge-outline">&#x1F441; {post.views}</div>
</div>
</div>
</div>
)
}
export default Post
+29
View File
@@ -0,0 +1,29 @@
import { useState,useEffect } from "react"
import Post from "./Post";
function Posts() {
const[posts,setPosts]=useState([]);
const letoltes=()=>{
fetch('https://dummyjson.com/posts')
.then(res=>res.json())
.then(adatok=>setPosts(adatok.posts))
.catch(err=>alert(err));
}
useEffect(()=>{
letoltes();
},[])
return (
<div>
<div>
{
posts.map((post)=>(<Post key={post.id} post={post} />))
}
</div>
</div>
)
}
export default Posts