From 361d255e954d6afbc0bbae293acf73ac8882f356 Mon Sep 17 00:00:00 2001
From: dan <dan.abramov@gmail.com>
Date: Sun, 28 Apr 2024 22:37:00 +0100
Subject: Remove useEffect from TimeElapsed (#3741)

---
 src/view/com/util/TimeElapsed.tsx | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

(limited to 'src/view/com/util/TimeElapsed.tsx')

diff --git a/src/view/com/util/TimeElapsed.tsx b/src/view/com/util/TimeElapsed.tsx
index 6ea41b82b..02b0f2314 100644
--- a/src/view/com/util/TimeElapsed.tsx
+++ b/src/view/com/util/TimeElapsed.tsx
@@ -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})
 }
-- 
cgit 1.4.1

