# Animate React Components with GSAP

React animations can affect the wrong elements or persist after a component unmounts. Use scoped GSAP selectors and React lifecycle cleanup to prevent these issues.

## Install

```bash
npx skillstore add greensock/gsap-react
```

## Metadata

- Status: approved
- Slug: greensock-gsap-react
- Skillstore revision: r1
- Version status: missing
- Tree hash: c99a6c4c140b5bff3ca1bb7f575d3a02e6cf1a7de67327159ae023c9f0263ce7
- Author: greensock
- GitHub username: greensock
- License: MIT
- Repository: https://github.com/greensock/gsap-skills/tree/aed9cfd3277740755f6bfc1155c7aa645403b760/skills/gsap-react
- Ref: 5a685fd3b2304f9e4cbf5164d3ac3186cd35324e
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands, network
- Quality score: 78
- Quality tier: bronze
- Public page: https://skillstore.pages.dev/skills/greensock-gsap-react
- Manifest: https://skillstore.pages.dev/api/skills/greensock-gsap-react/manifest

## Capabilities

- Register useGSAP and set up animations inside the hook.
- Target a DOM node by ref or scope selectors to a component root.
- Use dependencies and revertOnUpdate to rebuild animations when inputs change.
- Revert a GSAP context during effect cleanup when useGSAP is unavailable.
- Track animations created in event handlers with contextSafe and remove native listeners in cleanup.
- Keep DOM animation setup out of Next.js server renders.

## Use Cases

- Animate repeated components independently: Animate the children of each card list without selecting elements in other instances.
- Move animation setup out of server rendering: Set up a Next.js section animation inside a client-side hook so it does not run during server rendering.
- Review animation cleanup: Check whether animations and native event listeners are removed when a component unmounts.

## Prompt Templates

### Animate one element

```
Show how to fade in a React panel on mount with useGSAP. Target the panel with a ref.
```

### Scope a list animation

```
Animate the items in this React list with a stagger. Scope the selectors to the list root so multiple instances can animate independently.
```

### Rebuild a tween when a prop changes

```
Update this tween when endX changes. Set the hook dependencies and use revertOnUpdate to revert the previous animation before rebuilding it.
```

### Audit a Next.js animation lifecycle

```
Review this Next.js component for animation calls during server render. Wrap click-triggered tween creation with contextSafe and remove any native listeners during cleanup.
```

## Limitations

- The useGSAP examples require the separate @gsap/react package.
- DOM animations require a browser and cannot run during server rendering.
- contextSafe does not remove event listeners or cancel scheduled callbacks.
- The skill focuses on React integration, not detailed timeline or ScrollTrigger configuration.

## Best Practices

- Use a ref for a single target and a container scope for selector-based animations.
- Use revertOnUpdate when input changes should replace the previous animation.
- Wrap event-driven tween creation with contextSafe and remove native listeners in cleanup.

## Anti Patterns

- Use an unscoped class selector in a component that can appear more than once.
- Create DOM animations during server render.
- Create animations in a regular effect without reverting or disposing of them during cleanup.

## Security Audit

- Audited at: 2026-11-21T15:52:37.313\+00:00
- Summary: All 18 static alerts are false positives: Markdown formatting, a GSAP documentation link, and React cleanup guidance. The installation block lists standard npm commands for GSAP and its React integration; it does not use shell substitution. No evidence of prompt injection, system reconnaissance, or data exfiltration was found.

## Stats

- Views: 0
- Downloads: 1
- Favorites: 0
- Popularity score: 0
