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 ruleP1stack specificStack: react
useeffectssrserver-renderinghooks
Don't rely on useEffect in server-only rendered components
useEffect never runs during server rendering, so don't place behavior in it for components that render only on the server.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetsx
| 1 | // server-only component |
| 2 | function MobileNav() { |
| 3 | useEffect(() => { setupNav(); }, []); // never runs |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | // do the work where it can actually run (client component / inline script) |
| 2 | function MobileNav() { return <nav>...</nav>; } |
Explanation (EN)
Objašnjenje (HR)