Remove useEffect from TimeElapsed (#3741)
parent
256bb33de0
commit
361d255e95
|
@ -3,8 +3,6 @@ import React from 'react'
|
|||
import {useTickEveryMinute} from '#/state/shell'
|
||||
import {ago} from 'lib/strings/time'
|
||||
|
||||
// FIXME(dan): Figure out why the false positives
|
||||
|
||||
export function TimeElapsed({
|
||||
timestamp,
|
||||
children,
|
||||
|
@ -15,9 +13,11 @@ export function TimeElapsed({
|
|||
const tick = useTickEveryMinute()
|
||||
const [timeElapsed, setTimeAgo] = React.useState(() => ago(timestamp))
|
||||
|
||||
React.useEffect(() => {
|
||||
const [prevTick, setPrevTick] = React.useState(tick)
|
||||
if (prevTick !== tick) {
|
||||
setPrevTick(tick)
|
||||
setTimeAgo(ago(timestamp))
|
||||
}, [timestamp, setTimeAgo, tick])
|
||||
}
|
||||
|
||||
return children({timeElapsed})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue