Componentes de función, estado cerca de donde se usa, accesible por defecto.
Constitution — React SPA
Version 1.0.0 · Ratified 2026-11-10
These principles hold for every spec, plan and task of the project. A spec may add rules; it never weakens these.
-
Function components. Every component is a function component with hooks. The Rules of Hooks are enforced by
eslint-plugin-react-hooks, withexhaustive-depsas an error. -
State close to where it is used. State starts local and is lifted only when two siblings need it. A global store holds only app-wide state such as the session or the theme; server data lives in a query cache like TanStack Query and is never copied into a store.
-
Accessible by default. Semantic HTML comes first, every interactive element works with the keyboard and shows a visible focus, and every input has a label. Component tests run axe and allow zero violations.
-
Derive instead of syncing. A value that can be computed from props or state is computed during render. A
useEffectwhose only job is to set state from other state fails the review. -
Typed boundaries. TypeScript runs in
strictmode and API responses are parsed with a schema (for example zod) where they enter the app. Noanycrosses a component's props. -
Code split by route. Each route is loaded with
React.lazybehind a Suspense boundary. The initial JavaScript stays under 200 kB gzipped and CI fails the build above it. -
Tests from the user's side. React Testing Library queries by role, label and text, the way a person finds things. Tests that reach into internal state, or snapshot-only tests, fail the review.
-
Errors are contained. Each route has an error boundary that shows a message the person can recover from. The error is reported with its context; a blank screen is a defect.