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
reactresponsivecomponentsarchitecture
Split into separate components when breakpoints diverge in behavior
When mobile and desktop need meaningfully different markup/JS (e.g. drawer vs dropdown), render distinct components based on an isMobile check rather than morphing one with CSS.
PR: hegnar-components · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codescss
| 1 | .menu { /* desktop dropdown */ } |
| 2 | @media (max-width: 767px) { .menu { /* fully re-style into a drawer */ } } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | return isMobile ? <CategoryDrawer {...props} /> : <CategoryDropdown {...props} />; |
Explanation (EN)
Objašnjenje (HR)