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
reacthooksperformancedata-fetchingarchitecture
Call a data-fetching hook once high up and pass results down
Avoid calling the same non-cached fetching hook in both parent and child; call it once at the top level and pass the data as props to reduce duplicate requests and re-renders.
PR: hegnar-components · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetsx
| 1 | function Parent() { const data = useCategories(); return <Child />; } |
| 2 | function Child() { const data = useCategories(); /* fetches again */ } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | function Parent() { |
| 2 | const data = useCategories(); |
| 3 | return <Child categories={data} />; |
| 4 | } |
| 5 | function Child({ categories }) { /* uses prop */ } |
Explanation (EN)
Objašnjenje (HR)