This commit is contained in:
@@ -41,9 +41,10 @@ const useThinkTimer = (children: any) => {
|
||||
const timerRef = useRef<NodeJS.Timeout>()
|
||||
|
||||
useEffect(() => {
|
||||
if (isComplete) return
|
||||
|
||||
timerRef.current = setInterval(() => {
|
||||
if (!isComplete)
|
||||
setElapsedTime(Math.floor((Date.now() - startTime) / 100) / 10)
|
||||
setElapsedTime(Math.floor((Date.now() - startTime) / 100) / 10)
|
||||
}, 100)
|
||||
|
||||
return () => {
|
||||
@@ -53,11 +54,8 @@ const useThinkTimer = (children: any) => {
|
||||
}, [startTime, isComplete])
|
||||
|
||||
useEffect(() => {
|
||||
if (hasEndThink(children)) {
|
||||
if (hasEndThink(children))
|
||||
setIsComplete(true)
|
||||
if (timerRef.current)
|
||||
clearInterval(timerRef.current)
|
||||
}
|
||||
}, [children])
|
||||
|
||||
return { elapsedTime, isComplete }
|
||||
|
Reference in New Issue
Block a user