Skip to content

Commit

Permalink
add timestamp generation
Browse files Browse the repository at this point in the history
  • Loading branch information
firehawk89 committed Sep 24, 2023
1 parent 08e3d2c commit 39c371a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/app/page.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
'use client'

import { useEffect, useState } from 'react'
import Message from '@/components/message'

export default function Home() {
const [timeStamp, setTimeStamp] = useState(0)

useEffect(() => {
setTimeStamp(Math.floor(Date.now() / 1000))
}, [])

return (
<main className="flex flex-col gap-3 p-3">
<Message timeCreated="16.27">
<Message sentAt={timeStamp}>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Quae
architecto quis iure ex id voluptatum reprehenderit quod cum laboriosam.
Dicta temporibus quis sed assumenda tempore perferendis voluptas magnam
Expand All @@ -14,9 +21,9 @@ export default function Home() {
nulla accusamus commodi officia minus, ullam unde optio nisi similique
ab maiores? Perferendis aliquid minus laudantium error.
</Message>
<Message timeCreated="16.27">Hello, i'm a message! 😎</Message>
<Message timeCreated="16.28">I'm not empty</Message>
<Message timeCreated="16.30">...</Message>
<Message sentAt={timeStamp}>Hello, i'm a message! 😎</Message>
<Message sentAt={timeStamp}>I'm not empty</Message>
<Message sentAt={timeStamp}>...</Message>
</main>
)
}

0 comments on commit 39c371a

Please sign in to comment.