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
reliabilityside-effectsuxstate
Do not tie critical side effects to a UI path the user may skip
Persisting data, tracking, or other important side effects must not depend on a code branch that only runs if the user waits instead of dismissing the UI; trigger them on a reliable event or make them idempotent.
PR: abcn-web · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | // only fires if the user keeps the modal open until polling resolves |
| 2 | if (responseStatus === Status.ACTIVE) { |
| 3 | if (trackingId) trackSubscription(trackingId, email); |
| 4 | } |
| 5 | // if the user closes the modal first, tracking never happens |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | // fire-and-persist as soon as the action is initiated, independent of the modal |
| 2 | async function onSubscribe() { |
| 3 | await trackSubscription(trackingId, email); // happens regardless of modal lifetime |
| 4 | } |
| 5 |
|
| 6 | // confirmation polling only updates display state, not critical tracking |
| 7 | if (responseStatus === Status.ACTIVE) { |
| 8 | setStatus('confirmed'); |
| 9 | } |
Explanation (EN)
Objašnjenje (HR)