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 ruleP2stack specificStack: react
reduxcachingstate-shapereselect
Key store collections by id to enable caching and avoid refetching
Store fetched-per-key data in a keyed map (e.g. { sport: [...], news: [...] }) so previously loaded data can be reused and works cleanly with memoized selectors.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | // store overwrites items on every category change -> always refetch |
| 2 | state.category = { items: events }; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | state.category.items = { |
| 2 | sport: sportEvents, |
| 3 | news: newsEvents, |
| 4 | }; // keyed by category id; acts as a local cache |
Explanation (EN)
Objašnjenje (HR)