Skip to content

Commit

Permalink
check if post.comment !== undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
nex1994 committed Jan 8, 2025
1 parent 1726a3e commit 406c92c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function getComment(postId: number): Comment[] {
const posts: Post[] = postsFromServer.map(post => ({
...post,
user: getUser(post.userId),
comment: getComment(post.id),
comments: getComment(post.id),
}));

export const App: React.FC = () => (
Expand Down
4 changes: 2 additions & 2 deletions src/components/PostInfo/PostInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export const PostInfo: React.FC<Props> = ({ post }) => {
</div>
<p className="PostInfo__body">{post.body}</p>
<hr />
{post.comment !== undefined && post.comment.length > 0 ? (
<CommentList comments={post.comment} />
{post.comments !== undefined && post.comments.length > 0 ? (
<CommentList comments={post.comments} />
) : (
<b data-cy="NoCommentsMessage">No comments yet</b>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/types/Post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export interface Post {
id: number;
title: string;
body: string;
comment: Comment[];
comments: Comment[];
user: User | null;
}

0 comments on commit 406c92c

Please sign in to comment.