Add first version of article section

This commit is contained in:
= 2024-12-05 22:59:11 +01:00
parent 5c4ac78dee
commit 36dae30b4e
4 changed files with 57 additions and 0 deletions

View file

@ -0,0 +1,22 @@
import { useEffect, useState } from "react";
import ArticleCard from "./ArticleCard";
import { Article } from "../types";
export default function ArticlesSection() {
const [articles, setArticles] = useState<Article[]>([]);
useEffect(() => {
fetch('/api/article')
.then(response => response.json())
.then((data: Article[]) => setArticles(data));
}, []);
return (
<div>
{articles.map(article => (
<ArticleCard key={article.id} article={article} />
))}
</div>
)
}