Skip to content

Commit faab17d

Browse files
chore: fix timeout
1 parent 07ca1a2 commit faab17d

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

apps/sim/app/(landing)/blog/[slug]/animated-blocks.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ export function AnimatedColorBlocks() {
2525
const mounted = useRef(true)
2626

2727
function schedule(fn: () => void, ms: number) {
28-
const id = setTimeout(fn, ms)
28+
const id = setTimeout(() => {
29+
timers.current = timers.current.filter((timerId) => timerId !== id)
30+
fn()
31+
}, ms)
2932
timers.current.push(id)
3033
return id
3134
}
@@ -116,7 +119,10 @@ export function AnimatedColorBlocksVertical() {
116119
const verticalColors = [COLORS[0], COLORS[1], COLORS[2]] as const
117120

118121
function schedule(fn: () => void, ms: number) {
119-
const id = setTimeout(fn, ms)
122+
const id = setTimeout(() => {
123+
timers.current = timers.current.filter((timerId) => timerId !== id)
124+
fn()
125+
}, ms)
120126
timers.current.push(id)
121127
return id
122128
}

0 commit comments

Comments
 (0)