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
error-handlinguxcorrectnessdata-integrity
Don't optimistically show fetched data when the fetch failed
When a UI value depends on a request, don't fall back to showing the locally-edited value as if it were confirmed if that request fails, unless the underlying write was already persisted separately.
PR: vinify-frontend · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codets
| 1 | try { |
| 2 | const profile = await getCustomerProfile(); |
| 3 | setAddress(profile.address); |
| 4 | } catch { |
| 5 | setAddress(editedAddress); // shows edited value even though refresh failed |
| 6 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | try { |
| 2 | const profile = await getCustomerProfile(); |
| 3 | setAddress(profile.address); |
| 4 | } catch (error) { |
| 5 | showError(error); // surface failure; only keep edited value if the write was confirmed earlier |
| 6 | } |
Explanation (EN)
Objašnjenje (HR)