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
reactcomponentsseparation-of-concerns
Split a component in two when variants share almost nothing
If a component branches heavily on a variant flag and the branches share only a sliver of logic, two focused components are easier to read and use than one with internal if/else.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | const Selector = (props) => props.variant === 'mobile' |
| 2 | ? (<MobileSelect .../>) |
| 3 | : (<DesktopSelect .../>); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | // expose MobileSelector and DesktopSelector directly |
| 2 | export const MobileSelector = (props) => <MobileSelect .../>; |
| 3 | export const DesktopSelector = (props) => <DesktopSelect .../>; |
Explanation (EN)
Objašnjenje (HR)