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
reactui-librarystatereadability
Use a component library's render-prop state instead of manual index comparison
When a headless/UI library exposes selected/active/focus state via render props, use it rather than re-deriving active state by comparing indices yourself.
PR: hegnar-zephr-components · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetsx
| 1 | <Tab> |
| 2 | <TabItem className={index === activeIndex ? 'active' : ''} /> |
| 3 | </Tab> |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | <Tab> |
| 2 | {({ selected }) => <TabItem className={selected ? 'active' : ''} />} |
| 3 | </Tab> |
Explanation (EN)
Objašnjenje (HR)