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 ruleP2stack specificStack: react
reactperformanceconditional-rendering
Render the heavy branch conditionally rather than computing then discarding it
Gate the render call itself on the enabled flag instead of always building the content and hiding it inside the render method.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codejsx
| 1 | render() { |
| 2 | return <div>{this.renderArticles()}</div>; // bails internally if disabled |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejsx
| 1 | render() { |
| 2 | return <div>{this.props.articlesEnabled && this.renderArticles()}</div>; |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)