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
reactstatereadabilitytypescript
Prefer a plain boolean over boolean | null for loading flags
A loading flag that can be true/false/null forces awkward `!== null` guards downstream; default it to false unless you genuinely need to model 'never loaded' as a distinct state.
PR: hegnar-components · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | const [isLoading, setIsLoading] = useState<boolean | null>(null); |
| 2 | // ... |
| 3 | if (isLoading !== null && !items.length) { |
| 4 | return <Empty />; |
| 5 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const [isLoading, setIsLoading] = useState(false); |
| 2 | // ... |
| 3 | if (!items.length) { |
| 4 | return <Empty />; |
| 5 | } |
Explanation (EN)
Objašnjenje (HR)