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).
fullstack ruleP1universalStack: any
error-stateinitial-statecorrectness
Derive an initial error state when required data is missing
On first render/SSR, set an error state if essential data (e.g. profile, or both threads and replies) is absent, instead of assuming success.
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codetsx
| 1 | const [error, setError] = useState(false); // never reflects missing initialData |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | const hasData = initialData.profile && (initialData.threads || initialData.replies); |
| 2 | const [error, setError] = useState(!hasData); |
Explanation (EN)
Objašnjenje (HR)