React best practices and patterns for modern web applications
Add this skill
npx mdskills install PatrickJS/cursor-reactComprehensive React guidelines covering components, hooks, and performance, but lacks actionable agent triggers
1---2description: React best practices and patterns for modern web applications3globs: **/*.tsx, **/*.jsx, components/**/*4---56# React Best Practices78## Component Structure9- Use functional components over class components10- Keep components small and focused11- Extract reusable logic into custom hooks12- Use composition over inheritance13- Implement proper prop types with TypeScript14- Split large components into smaller, focused ones1516## Hooks17- Follow the Rules of Hooks18- Use custom hooks for reusable logic19- Keep hooks focused and simple20- Use appropriate dependency arrays in useEffect21- Implement cleanup in useEffect when needed22- Avoid nested hooks2324## State Management25- Use useState for local component state26- Implement useReducer for complex state logic27- Use Context API for shared state28- Keep state as close to where it's used as possible29- Avoid prop drilling through proper state management30- Use state management libraries only when necessary3132## Performance33- Implement proper memoization (useMemo, useCallback)34- Use React.memo for expensive components35- Avoid unnecessary re-renders36- Implement proper lazy loading37- Use proper key props in lists38- Profile and optimize render performance3940## Forms41- Use controlled components for form inputs42- Implement proper form validation43- Handle form submission states properly44- Show appropriate loading and error states45- Use form libraries for complex forms46- Implement proper accessibility for forms4748## Error Handling49- Implement Error Boundaries50- Handle async errors properly51- Show user-friendly error messages52- Implement proper fallback UI53- Log errors appropriately54- Handle edge cases gracefully5556## Testing57- Write unit tests for components58- Implement integration tests for complex flows59- Use React Testing Library60- Test user interactions61- Test error scenarios62- Implement proper mock data6364## Accessibility65- Use semantic HTML elements66- Implement proper ARIA attributes67- Ensure keyboard navigation68- Test with screen readers69- Handle focus management70- Provide proper alt text for images7172## Code Organization73- Group related components together74- Use proper file naming conventions75- Implement proper directory structure76- Keep styles close to components77- Use proper imports/exports78- Document complex component logic
Full transparency — inspect the skill content before installing.