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 617fb96 commit 1726a3e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/components/CommentInfo/CommentInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ import React from 'react';
import { Comment } from '../../types/Comments';

type Props = {
comment: Comment | null;
comment: Comment;
};

export const CommentInfo: React.FC<Props> = ({ comment }) => {
return (
<div className="CommentInfo">
<div className="CommentInfo__title">
<strong className="CommentInfo__name">{comment?.name}</strong>
<strong className="CommentInfo__name">{comment.name}</strong>

{' by '}

<a className="CommentInfo__email" href={`mailto:${comment?.email}`}>
{comment?.email}
<a className="CommentInfo__email" href={`mailto:${comment.email}`}>
{comment.email}
</a>
</div>

<div className="CommentInfo__body">{comment?.body}</div>
<div className="CommentInfo__body">{comment.body}</div>
</div>
);
};
3 changes: 2 additions & 1 deletion src/components/PostInfo/PostInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ export const PostInfo: React.FC<Props> = ({ post }) => {
<UserInfo user={post.user} />
</p>
</div>

<p className="PostInfo__body">{post.body}</p>
<hr />
{post.comment !== undefined && post.comment.length > 0 ? (
<CommentList comments={post.comment} />
) : (
<b data-cy="NoCommentsMessage">No comments yet</b>
)}
;
</div>
);
};

0 comments on commit 1726a3e

Please sign in to comment.