From fc30df1c4334ce079c71cd56740a56840edf8244 Mon Sep 17 00:00:00 2001 From: LEE <dlwodyd7613@ajou.ac.kr> Date: Thu, 23 Nov 2023 19:29:13 +0900 Subject: [PATCH] Add Post.js --- frontend/src/Post.js | 63 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 frontend/src/Post.js diff --git a/frontend/src/Post.js b/frontend/src/Post.js new file mode 100644 index 00000000..44cad7fb --- /dev/null +++ b/frontend/src/Post.js @@ -0,0 +1,63 @@ + +/* +title: { + type: String, + required: true, + }, + articleId: { + type: String, + unique: true, + }, + content: { + type: String, + required: true, + }, + imageUrls: { + type: [String], + }, + author: { + type: UserSchema, + required: true, + }, + comments: { + type: [CommentSchema], + }, + likes: { + type: [UserSchema], + }, + createdAt: { + type: Date, + default: Date.now, + }, +}); + +*/ + +import React, {useEffect, useState} from "react"; + +import { useParams } from 'react-router-dom'; + +function Post() { + const [post, setPost] = useState(null); + const { id } = useParams(); // URL에서 id를 가져온다./-> articleId + + useEffect(() => { + // id를 + // 예시: fetchPost(id).then(data => setPost(data)); + }, [id]); + + if (!post) { + return <div>Loading...</div>; + } + + return ( + <div> + <h1>{post.title}</h1> + <h2>{post.author}</h2> + <p>{post.content}</p> + {/* 게시글의 내용을 렌더링합니다. */} + </div> + ); +} + +export default Post; -- GitLab