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
reactpropsnamingtypes
Type boolean-like props as booleans and name initial-state props clearly
A toggle's value prop should be a boolean named for its meaning (checked), and the local initial-state prop should read as initial (initialChecked) rather than a stringly-typed defaultChecked.
PR: hegnar-zephr-components · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetsx
| 1 | interface ToggleProps { defaultChecked: string } |
| 2 | const [enabled, setEnabled] = useState(defaultChecked === 'true'); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | interface ToggleProps { checked: boolean } |
| 2 | const [checked, setChecked] = useState(initialChecked); |
Explanation (EN)
Objašnjenje (HR)