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
reactdata-fetchinguxerror-handling
Design UI for all fetch states: success, loading, error, empty
Every data fetch has success, loading, error, and empty states; explicitly design and render each rather than conflating them.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetsx
| 1 | if (!data.length) return <EmptyTable />; // error also shows as 'empty' |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | if (isLoading) return <Loading />; |
| 2 | if (error) return <ErrorState message={error} />; |
| 3 | if (!data.length) return <EmptyState />; |
| 4 | return <Table data={data} />; |
Explanation (EN)
Objašnjenje (HR)