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
reduxreselectmemoizationperformance
Derive computed store data with memoized selectors
Use a memoized selector library (e.g. reselect) to compute derived data from the store rather than recomputing it inline on every render or connect call.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | const mapState = state => ({ |
| 2 | events: state.category.items.filter(e => e.categoryId === state.filter.categoryId), |
| 3 | }); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const getEvents = createSelector( |
| 2 | [s => s.category.items, s => s.filter.categoryId], |
| 3 | (items, categoryId) => items.filter(e => e.categoryId === categoryId), |
| 4 | ); |
| 5 | const mapState = state => ({ events: getEvents(state) }); |
Explanation (EN)
Objašnjenje (HR)