blob: 7b2dd61f3c017a697ea512a1352451ff2cb69bfa (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import React from 'react'
import {observer} from 'mobx-react-lite'
import {ago} from 'lib/strings/time'
import {useStores} from 'state/index'
export const TimeElapsed = observer(function TimeElapsed({
timestamp,
children,
}: {
timestamp: string
children: ({timeElapsed}: {timeElapsed: string}) => JSX.Element
}) {
const stores = useStores()
const [timeElapsed, setTimeAgo] = React.useState(ago(timestamp))
React.useEffect(() => {
setTimeAgo(ago(timestamp))
}, [timestamp, setTimeAgo, stores.shell.tickEveryMinute])
return children({timeElapsed})
})
|