Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
frontend ruleP2universalStack: React
reacthooksnamingconventions
Don't disguise a plain function as a hook
A function that doesn't use React state/effects isn't a hook; don't prefix it with use or keep it under hooks/. Name it for what it does (isMobile/checkIfMobile).
PR: hegnar-components · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | // hooks/useMobile.ts |
| 2 | const useMobile = () => window.innerWidth < 768; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | // utils/isMobile.ts |
| 2 | const isMobile = () => window.innerWidth < 768; |
| 3 | // or a real hook using useMediaQuery if reactivity is needed |
Explanation (EN)
Objašnjenje (HR)