Skip to content

Instantly share code, notes, and snippets.

@cindywu
Created January 31, 2021 19:21
Show Gist options
  • Select an option

  • Save cindywu/e51f521feeed0f07de622140244a84ae to your computer and use it in GitHub Desktop.

Select an option

Save cindywu/e51f521feeed0f07de622140244a84ae to your computer and use it in GitHub Desktop.
PostList.tsx
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