Skip to content

Commit

Permalink
fix: respect spacing between words
Browse files Browse the repository at this point in the history
  • Loading branch information
zanechua committed Mar 12, 2022
1 parent 347ee93 commit 7890454
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ const Comment = ({ comment }) => {
console.log(comment);
const renderMessage = commentMessage => {
const messages = commentMessage.split('\n');
return messages.map(item => <p key={item}>{item}</p>);
return messages.map(item => (
<p key={item} className="whitespace-pre-wrap">
{item}
</p>
));
};

return (
<div className="comment py-3">
<h3 className="font-bold pb-2">{comment.name}</h3>
<h4 className="font-bold pb-6">{comment.date}</h4>
{renderMessage(comment.message)}
<div className="pb-2">{renderMessage(comment.message)}</div>
<hr />
</div>
);
Expand Down

0 comments on commit 7890454

Please sign in to comment.