// Review React components for best practices, hooks usage, performance issues, accessibility, and TypeScript type safety. Use when you need to audit existing React components or provide code review feedback.
| name | react-component-reviewer |
| description | Review React components for best practices, hooks usage, performance issues, accessibility, and TypeScript type safety. Use when you need to audit existing React components or provide code review feedback. |
This skill provides a systematic approach to reviewing React components, identifying issues, and suggesting improvements across multiple dimensions: best practices, hooks usage, performance, accessibility, and TypeScript type safety.
any type (use unknown if truly unknown)?Structure your review as follows:
## Component Review: [ComponentName]
### Summary
[1-2 sentence overview of the component and overall code quality]
### Critical Issues 🔴
[Issues that must be fixed - security, accessibility, breaking bugs]
### Performance Issues 🟡
[Performance problems that should be addressed]
### Best Practice Improvements 🔵
[Non-critical improvements for better code quality]
### Positive Highlights ✅
[Things the component does well - always include this!]
### Detailed Findings
#### [Category Name]
**Issue**: [Description with file:line reference]
**Current Code**:
```typescript
// problematic code
Recommendation:
// improved code
Rationale: [Why this change matters]
[Repeat for each finding]
## Examples
### Example Review
```markdown
## Component Review: UserProfile
### Summary
Well-structured component with good TypeScript usage, but has accessibility issues and unnecessary re-renders.
### Critical Issues 🔴
1. **Missing Keyboard Accessibility** (UserProfile.tsx:45)
- Custom dropdown not keyboard accessible
- Add onKeyDown handlers and ARIA attributes
2. **Incorrect Hook Dependencies** (UserProfile.tsx:23)
- useEffect missing `userId` dependency
- Can cause stale data issues
### Performance Issues 🟡
1. **Inline Function in JSX** (UserProfile.tsx:67)
```typescript
// Current
<Button onClick={() => handleClick(userId)}>Click</Button>
// Better
const handleButtonClick = useCallback(() => {
handleClick(userId);
}, [userId]);
<Button onClick={handleButtonClick}>Click</Button>
Props Interface Could Be More Specific (UserProfile.tsx:5)
status instead of stringMagic Number (UserProfile.tsx:89)
100 to named constant MAX_BIO_LENGTH
## Guidelines
### When Reviewing
- **Be Specific**: Always reference file names and line numbers
- **Provide Context**: Explain why something is an issue
- **Show Examples**: Include before/after code snippets
- **Be Constructive**: Balance criticism with positive feedback
- **Prioritize**: Not everything needs to be fixed immediately
- **Consider Trade-offs**: Performance optimizations have complexity costs
### What to Prioritize
1. **Critical Issues**: Security, accessibility violations, bugs
2. **Performance**: Only if there's actual evidence of problems
3. **Best Practices**: Code quality and maintainability
4. **Style**: Lowest priority, unless it affects readability
### What NOT to Flag
- Personal style preferences (if project has Prettier/ESLint)
- Premature optimizations without performance data
- Minor naming nitpicks
- Things that are already handled by automated tools
### Code Review Tone
- Professional and respectful
- Educational (explain the "why")
- Actionable (provide clear next steps)
- Balanced (acknowledge good code too)
## Common React Anti-Patterns to Watch For
1. **State Management Issues**
- Derived state that should be computed
- State that should be props
- Multiple setState calls that should be batched
2. **Effect Issues**
- useEffect that should be event handlers
- Missing cleanup functions
- Infinite loops from missing dependencies
3. **Performance**
- Creating components inside components
- Inline objects/arrays in JSX
- Not memoizing context values
4. **TypeScript**
- Using `any` instead of proper types
- Not typing event handlers
- Missing generic constraints
## Testing the Component
After reviewing, consider suggesting:
- Unit tests for logic
- Integration tests for user flows
- Accessibility tests with @testing-library/jest-dom
- Visual regression tests if applicable
## Limitations
This skill focuses on React component code review. It does not:
- Run automated tests (suggest running them separately)
- Check runtime performance (requires profiling)
- Verify design system compliance (requires design specs)
- Test in multiple browsers (requires manual/automated testing)
## Next Steps After Review
1. Create a prioritized list of changes
2. Discuss critical issues with the team
3. Create tickets/issues for non-trivial fixes
4. Consider refactoring if issues are widespread
5. Update team guidelines if patterns emerge