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 ruleP1universalStack: react
stateperformancererender
Keep flags that do not affect render out of component state
A boolean used only for internal bookkeeping (not read during render) should be an instance field, not state, so updating it does not trigger an unnecessary re-render.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codejavascript
| 1 | this.setState({ wasLoaded: true }); // wasLoaded is never read in render |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | private wasLoaded = false; |
| 2 | // ... |
| 3 | this.wasLoaded = true; |
Explanation (EN)
Objašnjenje (HR)