blob: dad46448c2a667310b11bd300469edd8238fbd31 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import React from 'react'
import {ago} from 'lib/strings/time'
import {useTickEveryMinute} from '#/state/shell'
// FIXME(dan): Figure out why the false positives
/* eslint-disable react/prop-types */
export function TimeElapsed({
timestamp,
children,
}: {
timestamp: string
children: ({timeElapsed}: {timeElapsed: string}) => JSX.Element
}) {
const tick = useTickEveryMinute()
const [timeElapsed, setTimeAgo] = React.useState(ago(timestamp))
React.useEffect(() => {
setTimeAgo(ago(timestamp))
}, [timestamp, setTimeAgo, tick])
return children({timeElapsed})
}
|