Using requestAnimationFrame with React Hooks

Animating with requestAnimationFrame should be easy, but if you haven’t read React’s documentation thoroughly then you will probably run into a few things that might cause you a headache. Here are three gotcha moments I learned the hard way.

Using requestAnimationFrame with React Hooks

August 2019

This is my first article on CSS tricks. I wrote it around the time React Hooks came out, and I spent an unreasonable amount of time figuring out how to make requestAnimationFrame work with the new setup.

After crystallizing my thoughts, I figured this is worth sharing, and why not publish it on a more serious website? While it has nothing to do with CSS, I contacted CSS-Tricks as Chris Coyier already knew my work from CodePen. Sarah Drasner praised the end result, and even Dan Abramov gave some feedback.

Read on CSS-Tricks
  • react