From d4e80387601b5092df7ff63aa0fdb09966043946 Mon Sep 17 00:00:00 2001 From: Bochkovskyi Date: Sun, 24 Sep 2023 19:45:47 +0300 Subject: [PATCH] update time formatting in message component --- src/components/message.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/message.jsx b/src/components/message.jsx index 203a72c..5dedae5 100644 --- a/src/components/message.jsx +++ b/src/components/message.jsx @@ -1,9 +1,16 @@ -import getFormattedTime from '@/utils/getFormattedDate' +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 (