Skip to content
Back to skills

React Hooks

ASecurity

Write React hooks with clean effect boundaries and measured memoization. Use when working with `useEffect`, custom hooks, refs, transitions, or hook dependency problems in React.

  • 24 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 4, 2026
developmentreactapiperformance

Works with

  • api

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned September 4, 2026

npx -y skills add gabrielmoreira/agent-skills-mirror --skill react-hooks --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of React Hooks?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for React Hooks
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gabrielmoreira-react-hooks/badge)](https://www.skillsdirectory.com/skills/gabrielmoreira-react-hooks)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: react-hooks
description: Write React hooks with clean effect boundaries and measured memoization. Use when working with `useEffect`, custom hooks, refs, transitions, or hook dependency problems in React.
metadata:
  triggers:
    files:
    - '**/*.tsx'
    - '**/*.jsx'
    keywords:
    - useEffect
    - useCallback
    - useMemo
    - useState
    - useRef
    - useContext
    - useReducer
    - useLayoutEffect
    - custom hook
---
# React Hooks Expert

## **Priority: P0 (CRITICAL)**

Effects sync external systems. Everything else should stay in render, event handlers, or custom hooks.

## Rules

- **Effects**: use `useEffect` only for subscriptions, timers, network lifecycle, DOM APIs, or other external systems.
- **Dependency churn**: objects recreated each render cause unstable dependencies; move to primitives, refs, or measured memoization.
- **Effect events**: use `useEffectEvent` when effect logic needs current props/state without widening dependencies.
- **Refs**: store mutable, non-render state in `useRef`.
- **Memoization**: add `useMemo` / `useCallback` only for measured hotspots or memoized child contracts.
- **Concurrency**: use `startTransition` / `useDeferredValue` for non-urgent updates.
- **Fetch cleanup**: use `AbortController` when an effect owns request cancellation.

## Verify

- [ ] Hooks stay at top level.
- [ ] Effects have cleanup when they subscribe, attach, or schedule.
- [ ] No effect exists only to derive render state from other render state.
- [ ] Dependency arrays reflect real external dependencies.
- [ ] Custom hooks hide internal wiring and expose a small API.

## Performance Checklist (Mandatory)

- [ ] **Rules of Hooks**: Called at top level? No loops/conditions?
- [ ] **Dependencies**: object/function deps exist for a reason, not by accident?
- [ ] **Cleanup**: `useEffect` subscriptions return cleanup functions?
- [ ] **Render Count**: component re-render excessively?

## Anti-Patterns

- **No Missing Deps**: Fix logic, don't disable linter.
- **No giant effects**: Split unrelated sync concerns.
- **No Derived State**: Compute during render, don't `useEffect` to sync state.
- **No Heavy Init**: Use lazy state initialization `useState(() => heavy())`.

## References

- [Framework Map](../references/framework-map.md)
- [Optimization Patterns](references/REFERENCE.md)

## Canonical response anchors

When this skill applies, preserve the following domain terminology or equivalent concrete examples in the answer when relevant:
- cleanup
- recreated

Files in this skill

  • SKILL.md2.5 KB
  • evals/evals.json2.5 KB
  • references/REFERENCE.md3.1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.