DEV Community

Discussion on: Need assistance with useEffect() dependencies

Collapse
 
ptifur profile image
Yar • Edited

Hey Spyros, thanks for suggestions!

I guess I should clarify that in fact I took the requestAnimationFrame() part from someone's example and didn't really change it as long as it's working. Just provided this condition to link the animation to the Stop button.

The way I understand it, requestAnimationFrame() does not work as a one line function, it has this intricate way of operating. It works only withing this looping function, generates the reference id with each run. And — I discovered it just now after more research — generates the timestamp each time and passes it back as an argument (time in my example).

You didn't ask 😜, but if you're interested, here's a great reference I found css-tricks.com/using-requestanimat...