Created
January 31, 2021 19:21
-
-
Save cindywu/e51f521feeed0f07de622140244a84ae to your computer and use it in GitHub Desktop.
PostList.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react' | |
| import { PostCard } from './PostCard' | |
| interface Post { | |
| abstract: any | |
| authors: any | |
| body: string | |
| created_at: string | |
| deleted_at: string | |
| id: number | |
| imprint_date: any | |
| imprint_type: any | |
| plugins: any | |
| publish_date: any | |
| published_at: any | |
| publisher: any | |
| slug: string | |
| title: string | |
| updated_at: string | |
| user_id: number | |
| visibility: string | |
| } | |
| interface Posts extends Array<Post>{} | |
| interface PostListProps { | |
| post: Post | |
| posts: Posts | |
| } | |
| export default function PostsList({ posts }: PostListProps) { | |
| console.log('posts', posts) | |
| const postElements = posts.map((post: Post) => { | |
| return <PostCard key={post.id} post={post} /> | |
| }) | |
| return <>{postElements}</> | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment