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
reactcomponentsencapsulationdry
Let a component own its own conditional rendering of internal pieces
If a child can decide whether to show a fallback (e.g. an avatar with/without an image), pass it the data and let it branch, instead of a ternary at every call site.
PR: hegnar-bellsheep-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetsx
| 1 | {entry.logo ? <img src={entry.logo} /> : <AvatarIcon />} // repeated everywhere |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | <Avatar icon={entry.logo} /> // Avatar internally renders img or fallback |
Explanation (EN)
Objašnjenje (HR)