Open
Description
Hi, I'm studying your videos, thanks a lot, but when I started the Code.tsx
part, there is a little doubt that return () => clearInterval(intervalId)
is used as the return value of the callback function for setTimeout. I think it will not work and should it be used as the return value of the useEffect callback function for clearing the memory.
useEffect(() => {
if (show && animated) {
let i = 0
setTimeout(() => {
const intervalId = setInterval(() => {
setText(code.slice(0, i))
i++
if (i > code.length) {
clearInterval(intervalId)
}
}, 15)
return () => clearInterval(intervalId)
}, animationDelay || 150)
}
}, [code, show, animated, animationDelay])
Metadata
Metadata
Assignees
Labels
No labels
Activity