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
reactredundancyconditional-renderingdry
Do not repeat the same guard check in parent and child
If a parent already guards on a condition before rendering a child, the child does not need to re-check the same condition.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetsx
| 1 | {quoteText && quoteDescription && ( |
| 2 | <QuoteOverImage quoteText={quoteText} quoteDescription={quoteDescription} /> |
| 3 | )} |
| 4 |
|
| 5 | // inside QuoteOverImage, the same check again |
| 6 | if (!quoteText) return null; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | {quoteText && quoteDescription && ( |
| 2 | <QuoteOverImage quoteText={quoteText} quoteDescription={quoteDescription} /> |
| 3 | )} |
| 4 |
|
| 5 | // QuoteOverImage trusts its required props |
Explanation (EN)
Objašnjenje (HR)