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
fallbackpriorityrendering
Render the image source before falling back to an initial/placeholder
When both a real image src and a generated initial are available, prefer the src; the fallback initial should only show when there's no image.
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codetsx
| 1 | return avatarInitial ? <Initial/> : <Image src={src}/>; // initial wins over src |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | if (src) return <Image src={src}/>; |
| 2 | if (avatarInitial) return <Initial/>; |
Explanation (EN)
Objašnjenje (HR)