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
reactconditional-renderingcssperformance
Conditionally render instead of hiding with display:none
When an element should not appear under a condition (e.g. mobile), skip rendering it rather than mounting it and hiding it with display:none, unless a library requires the node to stay mounted.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetsx
| 1 | .container { display: none; } /* mobile */ |
| 2 | <div className={styles.container}><Ad /></div> |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | {!isMobile && <div className={styles.container}><Ad /></div>} |
Explanation (EN)
Objašnjenje (HR)