home / skills / partme-ai / full-stack-skills / react-hooks
This skill guides you through React Hooks usage, patterns, and custom hooks to build performant, maintainable functional components.
npx playbooks add skill partme-ai/full-stack-skills --skill react-hooksReview the files below or copy the command above to add this skill to your agents.
---
name: react-hooks
description: Provides comprehensive guidance for React Hooks including useState, useEffect, useContext, useReducer, useMemo, useCallback, custom hooks, and hook patterns. Use when the user asks about React Hooks, needs to use hooks in functional components, create custom hooks, or optimize hook performance.
license: Complete terms in LICENSE.txt
---
## When to use this skill
Use this skill whenever the user wants to:
- [待完善:根据具体工具添加使用场景]
## How to use this skill
[待完善:根据具体工具添加使用指南]
## Best Practices
[待完善:根据具体工具添加最佳实践]
## Keywords
[待完善:根据具体工具添加关键词]
This skill provides comprehensive, practical guidance on React Hooks for building and optimizing functional components. It covers core hooks (useState, useEffect, useContext, useReducer), performance hooks (useMemo, useCallback), custom hook patterns, and migration tips from class components. The content focuses on actionable examples, common pitfalls, and performance trade-offs.
I explain what each hook does, when to choose it, and show concise code patterns for real-world scenarios. I provide step-by-step guidance for creating and testing custom hooks, managing side effects, and avoiding stale closures and unnecessary re-renders. The guidance includes debugging tips, dependency rules, and strategies to keep hooks predictable and maintainable.
When should I prefer useReducer over useState?
Choose useReducer for complex state updates, multiple related state values, or when state transitions are best modeled with actions and a reducer function.
How do I avoid stale closures in useEffect callbacks?
Include all external values in the effect's dependency array or use refs to hold mutable values that shouldn't trigger re-runs; prefer stable callback identities via useCallback when needed.