July 30, 2025 1 min read
GSAP ScrollTrigger with React: Performance Patterns
Tutorial
Depth: ●●○○○
How to use GSAP ScrollTrigger in React without causing memory leaks or janky animations.
GSAP ScrollTrigger with React: Performance Patterns
GSAP is powerful but doesn't automatically clean up in React. Here's how to avoid common pitfalls.
The Memory Leak Problem
ScrollTrigger instances persist even after components unmount. Without cleanup, you'll have dozens of zombie triggers eating memory.
The Solution: Proper Cleanup
Key Insight
gsap.context() is your friend. It scopes all animations and ScrollTriggers, making cleanup a single call.