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 ruleP2project specificStack: react
state-managementzustandstore
Access store state through the documented selector pattern
Read and update global store state via the established selector hook usage rather than an alternate access path with different semantics.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | useStore.getState().setInsref(id); // bypasses selector subscription |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const setInsref = useStore((state) => state.setInsref); |
| 2 | setInsref(id?.toString() ?? null); |
Explanation (EN)
Objašnjenje (HR)