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
reactapi-designyagniprops
Do not expose configuration as a prop unless multiple call sites need it
Keep a value internal (or derive it from an existing prop) until at least two call sites genuinely need to vary it; premature props bloat the component API.
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codetsx
| 1 | // Only one caller ever passes a non-default value |
| 2 | function Avatar({ size, imageSizes }: { size: number; imageSizes: string }) { |
| 3 | return <Image sizes={imageSizes} /* ... */ />; |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | // Derive from an existing prop; expose imageSizes only once a second caller needs it |
| 2 | function Avatar({ size }: { size: number }) { |
| 3 | const imageSizes = `${size}px`; |
| 4 | return <Image sizes={imageSizes} /* ... */ />; |
| 5 | } |
Explanation (EN)
Objašnjenje (HR)