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
reactssrperformancehooks
Skip the initial client fetch when data already came from SSR
When server-side rendering already provided the data, do not refetch it on mount; use an update-only effect so the first render uses the SSR payload.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetsx
| 1 | // refetches on mount even though SSR already gave us data |
| 2 | useEffect(() => { |
| 3 | fetchData(page); |
| 4 | }, [page]); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | // runs only on subsequent updates, reusing initial SSR data |
| 2 | useUpdateEffect(() => { |
| 3 | fetchData(page); |
| 4 | }, [page]); |
Explanation (EN)
Objašnjenje (HR)