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
reduxstate-managementarchitecturereact
Source connected components' data from the store, not local fetch state
In a Redux-connected feature, derive a component's data from the store rather than fetching into local component state, so it integrates with caching and shared state.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetsx
| 1 | class CategoryDashboard extends Component { |
| 2 | state = { events: [] }; |
| 3 | componentDidMount() { fetch().then(events => this.setState({ events })); } |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | // dispatch a thunk; read events from the store via connect |
| 2 | const mapState = state => ({ events: getEvents(state) }); |
Explanation (EN)
Objašnjenje (HR)