gsap-react_skill

This skill simplifies GSAP animations in React by providing useGSAP hooks, scoped refs, cleanup, and context utilities for reliable lifecycle handling.
  • JavaScript

6

GitHub Stars

2

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill bbeierle12/skill-mcp-claude --skill gsap-react

  • _meta.json343 B
  • SKILL.md11.3 KB

Overview

This skill provides a React-friendly integration for GSAP, including a useGSAP hook, ref patterns, context management, and cleanup strategies. It helps implement performant, lifecycle-aware animations inside React components and offers helpers for event-safe handlers and reusable animation hooks.

How this skill works

useGSAP runs GSAP code inside a scoped context so selectors and animations are limited to a container or set of refs. It returns context helpers like contextSafe for event handlers and automatically reverts timelines and ScrollTriggers on unmount. The patterns show single, multiple, and dynamic refs, timeline refs for external control, and explicit cleanup when needed.

When to use it

  • Animating elements in React components while respecting mount/unmount lifecycle
  • Building reusable animation hooks (fade, hover, controlled timelines)
  • Using GSAP ScrollTrigger inside React with automatic cleanup
  • Managing complex timelines from component controls (play, reverse, progress)
  • Handling event-driven animations safely with contextSafe

Best practices

  • Scope selector-based animations with a container ref to avoid global queries
  • Prefer refs over string selectors for frequently animated elements for performance
  • Kill or reuse tweens on rapid state changes to prevent buildup
  • Return cleanup functions or rely on useGSAP’s automatic revert for timelines and ScrollTriggers
  • Use timeline refs for externally controlled sequences and expose play/reverse/restart

Example use cases

  • A staggered list reveal using useGSAP with a container ref and .item selectors
  • A hover button using useHoverAnimation that returns event props bound with contextSafe
  • A controlled animation where parent props update timeline.progress(progress)
  • A dynamic list that maps DOM nodes into a Map ref and animates only new items
  • Scroll-triggered section reveals that register ScrollTrigger and kill triggers in cleanup

FAQ

useGSAP creates a GSAP context for each mount and automatically reverts that context on unmount, killing timelines and ScrollTriggers created inside the context.

When should I use refs vs class selectors?

Use refs for frequently animated elements for better performance and reliability; use scoped selectors when you want concise markup queries limited by a container ref.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
gsap-react skill by bbeierle12/skill-mcp-claude | VeilStrat