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
reactrenderinguxerror-handling
Render persistent UI (titles) outside data/error-conditional branches
A section title should stay visible regardless of loading or error state; don't nest it inside the branch that only renders when data is present.
PR: hegnar-web · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codetsx
| 1 | if (error) return <Error />; |
| 2 | return <><h2>Latest</h2><List items={data} /></>; // title vanishes on error |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | return ( |
| 2 | <> |
| 3 | <h2>Latest</h2> |
| 4 | {error ? <Error /> : <List items={data} />} |
| 5 | </> |
| 6 | ); |
Explanation (EN)
Objašnjenje (HR)