GSAPanimationReact

GSAP Animations in React: Patterns that Work

Jed Llenado08 Jan 20251 min read

GSAP and React can coexist beautifully if you follow a few rules. The key: always target DOM elements via refs, never by class selector.

Use useRef, Not Selectors

Class selectors break in concurrent mode and server-side rendering. Always attach a useRef and pass ref.current to GSAP.

Clean Up in useEffect

Always return a cleanup function from useEffect that kills your GSAP timelines: return () => tl.kill(). Otherwise you get memory leaks on navigation.

Enjoyed this? Get new posts by email

One short email when I publish something new. No spam, and you can reply to unsubscribe.

About the author

Jed Llenado

Jed is a Filipino software engineer with more than 12 years of experience, based in Saudi Arabia. He builds fast, secure websites and apps, backed by AI automation, digital marketing and UX design.

Request a quote
All Postsjedllenado.com