react
Modern React (19+) patterns: hooks discipline, Suspense, transitions, no class components.
npx rulepack add react
What it covers
- Function components only — no
class, nothis, no lifecycle methods; small functions with explicit prop types - Hooks discipline: call at the top level,
useState/useReducer/useContextchosen by need, anduseMemo/useCallbackonly when profiling justifies it (React 19's compiler covers most cases) - Async with
Suspenseboundaries anduse()instead of bespoke loading flags, plusstartTransitionfor non-urgent updates - Refs via
useReffor DOM nodes and mutable boxes; never read.currentduring render - Anti-patterns to avoid: derived state in
useState, mutating props, effects that only sync state to state, and index keys on reorderable lists
Source
Rules align with the official React documentation: https://react.dev/learn
License
MIT