← Todas las plantillas

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.

  1. Function components. Every component is a function component with hooks. The Rules of Hooks are enforced by eslint-plugin-react-hooks, with exhaustive-deps as an error.

  2. 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.

  3. 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.

  4. Derive instead of syncing. A value that can be computed from props or state is computed during render. A useEffect whose only job is to set state from other state fails the review.

  5. Typed boundaries. TypeScript runs in strict mode and API responses are parsed with a schema (for example zod) where they enter the app. No any crosses a component's props.

  6. Code split by route. Each route is loaded with React.lazy behind a Suspense boundary. The initial JavaScript stays under 200 kB gzipped and CI fails the build above it.

  7. 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.

  8. 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.