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).
fullstack ruleP1universalStack: react
architecturelayeringreact-hooksseparation-of-concerns
Don't call services directly from client-side hooks
Client hooks should call an action/endpoint, which calls the service; a client hook reaching straight into a backend service skips a layer and breaks the boundary.
PR: hegnar-journalist-boost · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | function useThing(id) { |
| 2 | return useQuery(['thing', id], () => ThingService.fetch(id)); // service in the client |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | function useThing(id) { |
| 2 | return useQuery(['thing', id], () => getThingAction(id)); // hook -> action -> service |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)