amey-thakur/ai-skills/react-hooks-discipline
Claude Code and agent skill by amey-thakur/ai-skills
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Write React hooks with correct dependencies and minimal effects so renders stay predictable. Use when adding useEffect, debugging stale closures or render loops, or extracting a custom hook.
Install
npx vskill@latest install amey-thakur/ai-skills/react-hooks-disciplineSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as amey-thakur/ai-skills/react-hooks-discipline.
React hooks discipline
Most hook bugs are one of two mistakes: lying to the dependency array, or using an effect to compute state that render could compute. Fix those two and the render graph becomes readable.
Method
- List every reactive value the effect reads as a dependency. Props,
state, and values derived from them all belong in the array. Do not silence react-hooks/exhaustive-deps; if a dependency causes a loop, the fix is to remove the dependency's reactivity (memoize it, move it into a ref, or lift it), not to hide it from the linter.
- Derive during render instead of syncing with an effect. If a value is
computable from props or state, compute it inline: `const full = first + " "
- last
. An effect that watches state tosetState` another value is a
double render and a drift bug waiting for the day the effect misses. Reserve useMemo for derivations proven expensive by measurement.
- Use effects only to synchronize with systems outside React. Network
subscriptions, event listeners, timers, imperative DOM APIs, and analytics are effects. Transforming data, filtering lists, and formatting are not. Every effect needs a cleanup that reverses its setup, or it leaks across remounts and Strict Mode double-invokes.
- Reset derived-from-props state with a key, not an effect. When a
component must clear internal state because an id changed, pass key={id} from the parent to remount it. An effect that watches id to reset state runs one render late and flashes stale content.
- Stabilize identities that feed dependency arrays. Wrap callbacks passed
to memoized children or effect deps in useCallback, and stabilize objects with useMemo, only where an unstable identity actually causes a re-run or re-render you measured. Blanket memoization adds noise without payoff.
- **Extract a custom hook when logic is stateful and reused, or gnarly and
named.** The trigger is a repeated stateful pattern (a useDebounce, a usePagination) or one effect-plus-state cluster complex enough to deserve a name and a test. Do not extract a hook that is called once and only wraps a single useState; that is indirection without reuse.
Boundaries
- Server-state caching (dedup, staleness, invalidation) belongs in a query
library; see frontend-data-fetching, not hand-rolled effects.
- Concurrent-mode edge cases (
useSyncExternalStore, transitions) need the
React docs; this covers everyday discipline.
- Class-component lifecycles are out of scope.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/frontend/react-hooks-discipline/SKILL.md
Popularity
- Repository stars
- 10
- Repository forks
- 2
- 7-day trend score
- 17
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/amey-thakur/ai-skills/react-hooks-discipline)