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
reactrenderingreadability
Conditionally render a component rather than mounting it to return null
When a component only renders for a non-null state, render it conditionally from the parent instead of always mounting it and returning null.
PR: hegnar-components · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codetsx
| 1 | function Modal({ activeAction }) { |
| 2 | if (!activeAction) return null; // always mounted |
| 3 | return <Dialog ... />; |
| 4 | } |
| 5 | <Modal activeAction={activeAction} /> |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | {activeAction && <Modal activeAction={activeAction} />} |
Explanation (EN)
Objašnjenje (HR)