Instruction file imported from robbiegerber-nu/nu (
.github/instructions/react-frontend.instructions.md). Copyright stays with the author.
React Frontend Standards
Components
- Functional components only — no class components
- One component per file, matching filename (
Navigation.jsx→function Navigation) - CSS module per component (
Navigation.cssimported inNavigation.jsx) - Props destructured in function signature
State & Auth
useAuth()fromreact-oidc-contextfor authentication stateuseRoles()fromRolesContextfor RBACuseStatefor local UI state — no external state management libraries- Never store tokens in localStorage or cookies — memory only
Testing
- Vitest + Testing Library (
@testing-library/react) - Test files in
src/test/matching<Component>.test.jsx - Mock
react-oidc-contextviavi.mock— never import real OIDC in tests - Use
screen.getByRole,getByText— avoidgetByTestIdunless necessary - Coverage thresholds: 90% lines, branches, functions, statements
Forbidden
- No
useEffectfor data that can be derived from props or auth state - No direct DOM manipulation — use React state and declarative rendering
- No
anytypes, no@ts-ignore - No snapshot tests — use explicit assertions