Commit 0a4db016 authored by Lee Soobeom's avatar Lee Soobeom
Browse files

send posting info to board

parent 18f1a3f8
import React, { useState, MouseEvent, useEffect } from "react"; import React, { useState, MouseEvent, useEffect } from "react";
import { Link } from "react-router-dom"; import { Link, useLocation } from "react-router-dom";
import { PostType } from "../types"; import { PostType } from "../types";
import Post from "../post/post"; import Post from "../post/post";
import { postApi } from "../apis"; import { postApi } from "../apis";
...@@ -8,11 +8,27 @@ interface Posts { ...@@ -8,11 +8,27 @@ interface Posts {
posts: PostType[]; posts: PostType[];
} }
interface Newpost {
state: PostType;
}
export default function BoardPage() { export default function BoardPage() {
const [posts, setPosts] = useState<PostType[]>(); const [posts, setPosts] = useState<PostType[]>();
const location = useLocation() as Newpost;
const newPost = location.state;
// console.log("get newPost Info", newPost);
const setNewPosts = (newpost: PostType) => {
const postArr = posts?.splice(-1, 0, newPost);
if (!(postArr === undefined)) {
setPosts(postArr);
}
};
useEffect(() => { useEffect(() => {
getDataList(); getDataList();
setNewPosts(newPost);
}, []); }, []);
// posts // posts
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment