| paths |
|
|---|
'use client' // Only if using hooks
// Imports (external → internal)
// Constants at module level
const CONFIG = { SPACING: 8 } as const
// Props interface
interface ComponentProps {
requiredProp: string
optionalProp?: boolean
}
export function Component({ requiredProp, optionalProp = false }: ComponentProps) {
// a. Refs
// b. External hooks (useParams, useRouter)
// c. Store hooks
// d. Custom hooks
// e. Local state
// f. useMemo
// g. useCallback
// h. useEffect
// i. Return JSX
}'use client'only when using React hooks- Always define props interface
- Extract constants with
as const - Semantic HTML (
aside,nav,article) - Optional chain callbacks:
onAction?.(id)
Extract when: 50+ lines, used in 2+ files, or has own state/logic
Keep inline when: < 10 lines, single use, purely presentational