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
reactcomponent-extractionorganization
Extract single-use JSX branches into a dedicated component
When a large conditional branch is only used by one page/route, move it into its own component near that view.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | const ThreadReply = () => { |
| 2 | if (isShared) { |
| 3 | return (/* 20 lines of shared-only JSX */); |
| 4 | } |
| 5 | return (/* normal JSX */); |
| 6 | }; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | if (isShared) return <SharedReply {...props} />; |
| 2 | return (/* normal JSX */); |
Explanation (EN)
Objašnjenje (HR)