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
reactnamingseparation-of-concernscomponents
Keep error/title handling out of a component named for a list
A component called *List should render the list; move surrounding concerns like fetching, error state, and the title to the parent so the name stays honest.
PR: hegnar-web · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codetsx
| 1 | function ForumList() { |
| 2 | const { data, error } = useFetch(); |
| 3 | if (error) return <Error />; |
| 4 | return <><h2>Title</h2><ul>{data.map(...)}</ul></>; |
| 5 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | function ForumSection() { |
| 2 | const { data, error } = useFetch(); |
| 3 | return <><h2>Title</h2>{error ? <Error /> : <ForumList items={data} />}</>; |
| 4 | } |
| 5 | function ForumList({ items }) { return <ul>{items.map(...)}</ul>; } |
Explanation (EN)
Objašnjenje (HR)