Skip to content

Commit

Permalink
chore(clock): assed suppresshydrationwarning to clock component
Browse files Browse the repository at this point in the history
  • Loading branch information
vildeopp committed Jul 11, 2023
1 parent a3c4d8b commit 6abd450
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions next-tavla/src/Shared/components/Clock/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { useEffect, useState } from 'react'

function Clock() {
const [currentTime, setCurrentTime] = useState<number | undefined>(
undefined,
)
const [currentTime, setCurrentTime] = useState(Date.now())

useEffect(() => {
setCurrentTime(Date.now())
const intervalId = setInterval(() => setCurrentTime(Date.now()), 1000)
return () => clearInterval(intervalId)
}, [])
Expand All @@ -16,7 +13,7 @@ function Clock() {
timeZone: 'Europe/Oslo',
}).format(currentTime)

return <span>{currentTime ? time : 'kunne ikke hente tiden'}</span>
return <span suppressHydrationWarning>{time}</span>
}

export { Clock }

0 comments on commit 6abd450

Please sign in to comment.