react
2
总安装量
1
周安装量
#71039
全站排名
安装命令
npx skills add https://github.com/yldgio/anomalyco --skill react
Agent 安装分布
opencode
1
Skill 文档
React Code Review Rules
Hooks Rules
- Hooks must be called at top level (not inside conditions, loops, or nested functions)
- Custom hooks must start with
useprefix useEffectmust have correct dependency array (no missing/extra deps)useEffectcleanup functions must be returned for subscriptions/timers
State Management
- State should be as local as possible (don’t lift prematurely)
- Avoid redundant state (derive values instead of storing)
- Use
useReducerfor complex state logic with multiple sub-values - Prefer controlled components over uncontrolled (except file inputs)
Performance
- Wrap expensive computations in
useMemo - Stabilize callbacks with
useCallbackwhen passed to memoized children - Use
React.memo()for components that render often with same props - Avoid creating objects/arrays inline in JSX (causes re-renders)
Component Design
- Single responsibility: one component, one purpose
- Props should be minimal and well-typed
- Avoid prop drilling > 2 levels (use Context or composition)
- Prefer composition over prop-based conditional rendering
Accessibility
- Interactive elements must be keyboard accessible
- Use semantic HTML (
buttonnotdiv onClick) - Images need
alttext - Form inputs need associated labels
Anti-patterns
- Avoid
useEffectfor state derivation (compute during render instead) - Avoid
useEffecton mount for data that could be fetched server-side - Avoid index as key in lists that reorder