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
reactredundancyreadability
Pass undefined directly for optional attributes that may be absent
When an attribute should simply be omitted if a value is missing, pass the value (or undefined) directly rather than wrapping it in a `value ? value : undefined` ternary. React drops undefined attributes, so the ternary is redundant.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codejsx
| 1 | <a data-k5a-pos={tracking ? tracking : undefined} /> |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejsx
| 1 | <a data-k5a-pos={tracking} /> // undefined when not passed; React omits it |
Explanation (EN)
Objašnjenje (HR)