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 ruleP1stack specificStack: react
react-routerdata-fetchingoptimistic-uiarchitecture
Let the router own data fetching, optimistic UI, and cancellation
For data loading and mutations in a routed app, use the router's loader/action and fetcher APIs (which handle abort signals, revalidation and optimistic UI) instead of hand-rolling fetch + abort logic inside components.
PR: hegnar-bellsheep-web · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetsx
| 1 | useEffect(() => { |
| 2 | const c = new AbortController(); |
| 3 | followPerson(id, { signal: c.signal }); |
| 4 | return () => c.abort(); |
| 5 | }, [id]); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | const fetcher = useFetcher(); |
| 2 | <fetcher.Form method="post" action="/myfa/following"> |
| 3 | <input type="hidden" name="personId" value={id} /> |
| 4 | <button type="submit">Follow</button> |
| 5 | </fetcher.Form> |
Explanation (EN)
Objašnjenje (HR)