Skip to content

Commit

Permalink
deconstructed comment in component
Browse files Browse the repository at this point in the history
  • Loading branch information
syavaYki committed Sep 27, 2024
1 parent 6c8956c commit e1a5d0a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/components/Comment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,27 @@ type Props = {
};

export const CommentObj: React.FC<Props> = ({ comment, onDelete }) => {
const { id, email, name, body } = { ...comment };

return (
<article key={comment.id} className="message is-small" data-cy="Comment">
<article key={id} className="message is-small" data-cy="Comment">
<div className="message-header">
<a href={`mailto:${comment.email}`} data-cy="CommentAuthor">
{comment.name}
<a href={`mailto:${email}`} data-cy="CommentAuthor">
{name}
</a>
<button
data-cy="CommentDelete"
type="button"
className="delete is-small"
aria-label="delete"
onClick={() => onDelete(comment.id)}
onClick={() => onDelete(id)}
>
delete button
</button>
</div>

<div className="message-body" data-cy="CommentBody">
{comment.body}
{body}
</div>
</article>
);
Expand Down

0 comments on commit e1a5d0a

Please sign in to comment.