Rule

0 installs · 0 said it worked

PatrickJS@patrickjs·
CodingRule· for Cursor

Review and write React code following modern best practices

A rules file guiding an AI assistant to write React components with functional patterns, hooks discipline, performance, forms, error handling, testing, and accessibility.

People use this for

  • react best practices rules file
  • react hooks coding guidelines
  • write react components accessibly
  • react component performance patterns
  • react error handling and testing rules
Name
review-and-write-react-code-following-modern-best-practices
Works with
Cursor
License
CC0(as observed at the source)
Version
v1 · updated Nov 29, 2026
Imported · UnclaimedCC0

Imported on Nov 29, 2026 from github.com . License observed at the source on Nov 29, 2026: CC0.

Are you the author?Claim this profileRequest removal

Use this rule

$ curl -fsSL "https://promptcommunity.dev/api/v1/posts/review-and-write-react-code-following-modern-best-practices-ucwq/export/mdc" -o .cursor/rules/review-and-write-react-code-following-modern-best-practices.mdc

Then open a new session; Cursor picks it up from .cursor/rules/.

Download review-and-write-react-code-following-modern-best-practices.mdc
Manual install

Save review-and-write-react-code-following-modern-best-practices.mdc as .cursor/rules/review-and-write-react-code-following-modern-best-practices.mdc for this project or ~/.cursor/rules/review-and-write-react-code-following-modern-best-practices.mdc for every project, then start a new session.

Rule


description: "React best practices and patterns for modern web applications" globs: **/*.tsx, /*.jsx, components//* alwaysApply: false

React Best Practices

Component Structure

  • Use functional components over class components
  • Keep components small and focused
  • Extract reusable logic into custom hooks
  • Use composition over inheritance
  • Implement proper prop types with TypeScript
  • Split large components into smaller, focused ones

Hooks

  • Follow the Rules of Hooks
  • Use custom hooks for reusable logic
  • Keep hooks focused and simple
  • Use appropriate dependency arrays in useEffect
  • Implement cleanup in useEffect when needed
  • Avoid nested hooks

State Management

  • Use useState for local component state
  • Implement useReducer for complex state logic
  • Use Context API for shared state
  • Keep state as close to where it's used as possible
  • Avoid prop drilling through proper state management
  • Use state management libraries only when necessary

Performance

  • Implement proper memoization (useMemo, useCallback)
  • Use React.memo for expensive components
  • Avoid unnecessary re-renders
  • Implement proper lazy loading
  • Use proper key props in lists
  • Profile and optimize render performance

Forms

  • Use controlled components for form inputs
  • Implement proper form validation
  • Handle form submission states properly
  • Show appropriate loading and error states
  • Use form libraries for complex forms
  • Implement proper accessibility for forms

Error Handling

  • Implement Error Boundaries
  • Handle async errors properly
  • Show user-friendly error messages
  • Implement proper fallback UI
  • Log errors appropriately
  • Handle edge cases gracefully

Testing

  • Write unit tests for components
  • Implement integration tests for complex flows
  • Use React Testing Library
  • Test user interactions
  • Test error scenarios
  • Implement proper mock data

Accessibility

  • Use semantic HTML elements
  • Implement proper ARIA attributes
  • Ensure keyboard navigation
  • Test with screen readers
  • Handle focus management
  • Provide proper alt text for images

Code Organization

  • Group related components together
  • Use proper file naming conventions
  • Implement proper directory structure
  • Keep styles close to components
  • Use proper imports/exports
  • Document complex component logic

No result recorded yet. Added it? File a Tried-it report so the next person knows how it went in your editor.

Tried it

Reports from people who added this rule to their editor. They roll up into the badges above.

No one has filed a report yet. Try the prompt and be the first.

License: CC0v1 · published Nov 29, 2026

Comments

No comments yet. If you tried this prompt, say how it went.