manifold/web/components/relative-timestamp.tsx
Marshall Polaris c44f223064
Fix some hydration issues (#1033)
* Extract `useIsClient` hook

* Fix a bunch of hydration bugs relevant to the contract page
2022-10-12 14:07:07 -07:00

17 lines
445 B
TypeScript

import { DateTimeTooltip } from './datetime-tooltip'
import { fromNow } from 'web/lib/util/time'
import { useIsClient } from 'web/hooks/use-is-client'
export function RelativeTimestamp(props: { time: number }) {
const { time } = props
const isClient = useIsClient()
return (
<DateTimeTooltip
className="ml-1 whitespace-nowrap text-gray-400"
time={time}
>
{isClient && fromNow(time)}
</DateTimeTooltip>
)
}