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
reactcomponentsarchitectureencapsulation
Create components to encapsulate behavior, not only for reuse
A subcomponent is justified when it cleanly encapsulates a self-contained piece of UI/behavior, even if used once; reusability is a bonus, not the sole criterion.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codejsx
| 1 | // everything inlined in Header because 'it won't be reused' |
| 2 | renderSearchLayer() { /* ... */ } |
| 3 | renderMenuLayer() { /* ... */ } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejsx
| 1 | <SearchLayer ... /> |
| 2 | <MenuLayer ... /> |
| 3 | // each encapsulates its own behavior; changes stay localized |
Explanation (EN)
Objašnjenje (HR)