react-rerender-auditor
2
总安装量
2
周安装量
#65227
全站排名
安装命令
npx skills add https://github.com/handxr/react-rerender-auditor --skill react-rerender-auditor
Agent 安装分布
gemini-cli
2
opencode
2
antigravity
2
github-copilot
2
windsurf
2
codex
2
Skill 文档
React Re-render & Performance Auditor
Static analysis tool that scans React code for patterns causing unnecessary re-renders.
Workflow
- Identify target file or directory to audit
- Run the auditor script
- Review findings by severity (errors first, then warnings)
- Apply fixes starting with highest-impact issues (context providers > inline creations > hooks)
- Re-run to verify fixes
Running the Auditor
# Single file
python scripts/react_rerender_auditor.py src/components/Dashboard.tsx
# Entire project
python scripts/react_rerender_auditor.py src/
# Include low-severity hints
python scripts/react_rerender_auditor.py src/ --strict
# Machine-readable output
python scripts/react_rerender_auditor.py src/ --json
What It Detects
Inline Creations (highest impact)
prop={{ key: val }}â inline objects create new reference every renderprop={[1, 2, 3]}â inline arrays create new reference every renderonClick={() => fn()}â inline functions create new reference every renderdate={new Date()}â new instances in JSX props
Context Issues (cascading impact)
<Provider value={{ ... }}>â inline value re-renders ALL consumers
useEffect Anti-patterns (bugs)
useEffect(async () => ...)â returns Promise instead of cleanupuseEffect(() => { setState() })without deps â infinite loop- useEffect with 3+ setState calls â cascading re-renders
Expensive Render Operations
JSON.parse()/JSON.stringify()without useMemo.sort()in render body (mutates + expensive).filter().map()chains without memoizationnew RegExp()recreated every render
Component Complexity
- Components over 250 lines (should split)
- Components with 10+ props (API too complex)
- Components with 5+ useState hooks (use useReducer)
{...props}spreading (forwards unknown re-render triggers)
Interpreting Results
!!Error: Will cause bugs or severe performance problems â fix immediately!~Warning: Causes unnecessary re-renders in practice â fix in hot paths~~Info: Code smell, may cause issues at scale (only with--strict)
Fix Priority
- Context providers â one fix eliminates re-renders across entire subtrees
- useEffect bugs â async effects and infinite loops are correctness issues
- Inline creations in lists â
items.map(item => <Child config={{ ... }} />)is N re-renders - Expensive operations â
JSON.parseand.sort()in frequently-rendered components - Component complexity â architectural improvements for long-term maintainability
Detailed Rules
Read references/rerender-rules.md for full documentation on each detection rule, including React 19 considerations and when NOT to optimize.