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 ruleP0stack specificStack: react
reacthydrationuseIdbugssr
Don't rely on useId for IDs shared across multiple hydration roots
useId restarts its counter per hydration mount point, so multiple roots produce colliding ids (r0, r0, r0); don't use it where IDs must be globally unique on the page.
PR: hegnar-web · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codetsx
| 1 | function ClientComponent() { |
| 2 | const id = useId(); // collides across multiple hydrateRoot mount points |
| 3 | return <div id={id} />; |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | function ClientComponent({ id }: { id: string }) { |
| 2 | // pass a guaranteed-unique id from the caller instead |
| 3 | return <div id={id} />; |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)