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
reactfunction-componentconsistency
Prefer function components for stateless/simple UI
Use function components instead of class components when there is no complex lifecycle need; they are shorter and the codebase default.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetsx
| 1 | class BlinkCircle extends Component<IBlinkCircleProps, any> { |
| 2 | public render() { return <div className={styles.circle} />; } |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | const BlinkCircle: FC<IBlinkCircleProps> = () => <div className={styles.circle} />; |
Explanation (EN)
Objašnjenje (HR)