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 ruleP2universalStack: react
reactcohesioncomponentsrefactoring
Move related rendering/derivation logic into the component that owns it
Logic that derives data for a child (building its URL, choosing its heading) should live inside that child component rather than in the parent's render path.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codejsx
| 1 | // Parent computes goToNewsPageUrl then passes it down |
| 2 | renderNewsList(data) { |
| 3 | const url = this.getCategoryUrl(data.headerData.title); |
| 4 | return <NewsNetGuide {...data} urlToPage={url} />; |
| 5 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejsx
| 1 | // NewsNetGuide derives its own urlToPage from the data it already receives |
| 2 | <NewsNetGuide {...data} /> |
Explanation (EN)
Objašnjenje (HR)