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
reactpropsdefaultsapi-design
Make props optional with sensible defaults rather than forcing callers to pass them
Declare configuration props optional and supply defaultProps so consumers only override what they need.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | interface SearchFieldProps { |
| 2 | maxItems: number; |
| 3 | minCharsForSearch: number; |
| 4 | } |
| 5 | // every caller must pass both |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | interface SearchFieldProps { |
| 2 | maxItems?: number; |
| 3 | minCharsForSearch?: number; |
| 4 | } |
| 5 | SearchField.defaultProps = { maxItems: 10, minCharsForSearch: 3 }; |
Explanation (EN)
Objašnjenje (HR)