mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
at session-alignment 22 lines 548 B view raw
1import React from 'react' 2import {ago} from 'lib/strings/time' 3import {useTickEveryMinute} from '#/state/shell' 4 5// FIXME(dan): Figure out why the false positives 6 7export function TimeElapsed({ 8 timestamp, 9 children, 10}: { 11 timestamp: string 12 children: ({timeElapsed}: {timeElapsed: string}) => JSX.Element 13}) { 14 const tick = useTickEveryMinute() 15 const [timeElapsed, setTimeAgo] = React.useState(ago(timestamp)) 16 17 React.useEffect(() => { 18 setTimeAgo(ago(timestamp)) 19 }, [timestamp, setTimeAgo, tick]) 20 21 return children({timeElapsed}) 22}