Skip to content

Commit

Permalink
remove useState and useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
firehawk89 committed Sep 25, 2023
1 parent cfac283 commit da7fe85
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/components/message.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import { useEffect, useState } from 'react'
import { timeFormatter } from '@/utils/getFormattedDate'
import Image from 'next/image'
import Link from 'next/link'

export default function Message({ sentAt, children }) {
const [time, setTime] = useState(0)
const { format: formatTime } = timeFormatter()

useEffect(() => {
setTime(formatTime(sentAt))
}, [sentAt, formatTime])

return (
<div className="flex items-end gap-2">
<Link className="rounded-full overflow-hidden" href="/">
Expand All @@ -24,7 +18,7 @@ export default function Message({ sentAt, children }) {
</Link>
<div className="flex justify-between gap-2 rounded-lg rounded-bl-none w-fit max-w-md py-2 px-3 bg-orange-100">
<p className="break-words">{children}</p>
<span className="text-xs self-end">{time}</span>
<span className="text-xs self-end">{formatTime(sentAt)}</span>
</div>
</div>
)
Expand Down

0 comments on commit da7fe85

Please sign in to comment.