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
reactstateredundancy
Remove redundant state that duplicates another flag
If two pieces of state always hold the same value, drop one; carrying both invites them drifting out of sync.
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codets
| 1 | const [isTruncatable, setIsTruncatable] = useState(false); |
| 2 | const [shouldClamp, setShouldClamp] = useState(false); // always == isTruncatable |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | const [isTruncatable, setIsTruncatable] = useState(false); |
| 2 | // derive clamp from isTruncatable && !isExpanded |
Explanation (EN)
Objašnjenje (HR)