post.tsx 793 Bytes
Newer Older
1
import React, { MouseEventHandler } from "react";
Lee Soobeom's avatar
Lee Soobeom committed
2
import { Link } from "react-router-dom";
3
import { PostType } from "../types";
Lee Soobeom's avatar
Lee Soobeom committed
4
import { IntoPost } from "./intopost";
5

Lee Soobeom's avatar
Lee Soobeom committed
6
export type Props = {
7
8
9
  post: PostType;
  handleClick: MouseEventHandler;
};
Lee Soobeom's avatar
Lee Soobeom committed
10
// Link opts = state : send obj , useLocation location.state
11
12
13
14
export default function Post({ handleClick, post }: Props) {
  return (
    <div className="flex flex-row h-16 divide-x-2 border-2 border-solid">
      <div className="basis-full">
Lee Soobeom's avatar
Lee Soobeom committed
15
16
17
18
19
        <Link to={`/post/${post._id}`} state={post}>
          <button id={post._id} onClick={handleClick}>
            {post.title}
          </button>
        </Link>
20
21
22
23
24
25
      </div>
      <div className="basis-3/12">{post.date}</div>
      <div className="basis-2/12">{post.counts}</div>
    </div>
  );
}