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
reactssrpropsimmutability
Pass serializable literal props and never mutate props
With server-side rendering, non-literal prop values (like URL objects) get coerced to strings, so prefer serializable literals; and never reassign properties of props — copy into a local variable instead.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetsx
| 1 | function Tweet({ info }) { |
| 2 | info.url = new URL(info.url); // mutates props + non-literal |
| 3 | return <a href={info.url.href}>link</a>; |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | function Tweet({ info }) { |
| 2 | const linkedPageUrl = new URL(info.url); // local, not a prop mutation |
| 3 | return <a href={linkedPageUrl.href}>link</a>; |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)