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
reactfile-organizationrenderpurity
Keep one component per file and define non-reusable JSX outside the render body
Favor one component per file; small non-reusable JSX may stay in the same file but should be defined outside the component body (ideally as a pure function) so it isn't recreated each render and can be extracted later.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetsx
| 1 | function Box() { |
| 2 | const Header = () => <h2>Title</h2>; // recreated every render |
| 3 | return <section><Header /></section>; |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | function Header() { return <h2>Title</h2>; } |
| 2 |
|
| 3 | function Box() { |
| 4 | return <section><Header /></section>; |
| 5 | } |
Explanation (EN)
Objašnjenje (HR)