Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Use ReactNode as the render return type for flexibility
Use a render return type matching the supported outputs and toolchain; ReactNode is useful when null, text or other nodes are part of the contract.
Bad example
| 1 | public render(): JSX.Element { |
| 2 | return <button onClick={onClick} />; |
| 3 | } |
Explanation (EN)
An unnecessarily narrow render signature can exclude intended null or text results.
Objašnjenje (HR)
Good example
| 1 | public render(): ReactNode { |
| 2 | return <button onClick={onClick} />; |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
Choose a render return type that expresses the actual public contract and is accepted by the installed TypeScript and React type versions.
Exceptions / Tradeoffs (EN)
JSX fragments are already elements. A deliberately narrow ReactElement contract or inferred return can be correct; older toolchains may not accept a broad ReactNode function as JSX.