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
reactjsxreadabilitydry
Assign a conditionally-chosen component to a capitalized const before rendering
When the component to render depends on a condition, pick it into a PascalCase const and render <Component /> once, instead of branching the JSX.
PR: vinify-frontend · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetsx
| 1 | let FavoriteStoreIcon = StarOutlineIcon; |
| 2 | if (favoriteStores.includes(option.id)) { |
| 3 | FavoriteStoreIcon = StarIcon; |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | const FavoriteStoreIcon = favoriteStores.includes(option.id) ? StarIcon : StarOutlineIcon; |
Explanation (EN)
Objašnjenje (HR)