import { Card, Comment, Spin, Row } from 'antd'; import React, { FC, useMemo } from 'react'; import { useFetch, FetchState } from 'tipple'; export const Post: FC<{ post: PostData }> = ({ post }) => { const [comments] = useFetch( `/comments/?postId=${post.id}`, { domains: ['comments'] } ); const commentsContent = useMemo(() => getComments(comments), [comments]); return (

{post.title}

{commentsContent}
); }; const getComments = (comments: FetchState) => { if (comments.fetching && comments.data === undefined) { return ; } if (comments.error || comments.data === undefined) { return

Unable to fetch comments

; } return ( <>
{comments.data.length} replies

{comments.data.map(comment => ( ))} ); };