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
reactpropsnamingflexibility
Name and type props for what they accept
If a prop will not always be a specific format (e.g. an HTML string), name it generically (htmlContent), make it optional, and fall back to children.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetsx
| 1 | interface Props { body: string; } |
| 2 | const PostBody = ({ body }: Props) => ( |
| 3 | <div dangerouslySetInnerHTML={{ __html: body }} /> |
| 4 | ); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | interface Props { htmlContent?: string; children?: React.ReactNode; } |
| 2 | const PostBody = ({ htmlContent, children }: Props) => |
| 3 | htmlContent ? <div dangerouslySetInnerHTML={{ __html: htmlContent }} /> : <>{children}</>; |
Explanation (EN)
Objašnjenje (HR)