react-hooks-components
2
总安装量
2
周安装量
#71697
全站排名
安装命令
npx skills add https://github.com/sraloff/gravityboots --skill react-hooks-components
Agent 安装分布
opencode
2
claude-code
2
github-copilot
2
codex
2
kimi-cli
2
gemini-cli
2
Skill 文档
React Hooks & Components
When to use this skill
- Creating functional components.
- Designing custom hooks.
- optimizing re-renders.
1. Hooks Rules
- Top Level: Only call hooks at the top level of the component/hook.
- Dependencies: Be honest with dependency arrays in
useEffect,useCallback, anduseMemo. Use linter to enforce.
2. Memoization
- UseMemo/UseCallback: Use only when the calculation is expensive OR when passing functions/objects as props to memoized children. Over-memoization adds overhead.
- Stable References: Remember that objects/arrays defined inside component body are new references every render.
3. Component Composition
- Props: Pass
children(slots) instead of prop drilling complex state. - Container/Presenter: Separate logic (data fetching) from UI rendering where complex.
4. State Management
- Local vs Global: Keep state as local as possible. Move up only when siblings need to share it.
- Context: Use Context for low-velocity global data (theme, user). For high-velocity data, use a signal-based library or optimized subscriber pattern.