import React, { useState, MouseEvent } from "react"; import { Link } from "react-router-dom"; import { PostType } from "../types"; import Post from "../post/post"; interface Posts { posts: PostType[]; } export const fakes = [ { userId: "lsb", title: "여행가고싶다...", date: "2022-06-30", counts: 0, theme: "surfing", city: "seoul", }, { userId: "lsb", title: "바다!바다!바다!", date: "2022-08-01", counts: 0, theme: "surfing", city: "seoul", }, { userId: "lsb", title: "Jeju-island", date: "2022-9-10", counts: 0, theme: "surfing", city: "seoul", }, { userId: "lsb", title: "마! 부싼 가봤나!", date: "2022-9-22", counts: 0, theme: "surfing", city: "seoul", }, { userId: "lsb", title: "Daegu", date: "2022-10-1", counts: 0, theme: "ski", city: "Daegu", }, { userId: "lsb", title: "강원도 감자는 맛있다.", date: "2022-12-12", counts: 0, theme: "camping", city: "강원도", }, { userId: "lsb", title: "부산남자의 서울여행", date: "2022-12-25", counts: 0, theme: "activity", city: "seoul", }, ]; export default function BoardPage() { const [posts, setPosts] = useState(fakes); const titleHandleClick = (event: MouseEvent) => { const postId = event.currentTarget.id; const newposts = [...posts]; newposts.forEach((post) => { if (post.userId === postId) { post.counts = post.counts + 1; return; } }); setPosts(newposts); }; return (
`Travel Report's Board`
`여행지 후기를 남겨주세요!`
{" "} {/* Link */}
Title
Date
Clicks
{posts.map((post) => ( ))}
); }