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 ruleP2universalStack: react
reactdryconfig
Drive repeated UI from a config array instead of duplicated JSX
Define lists of similar elements as data in a config file and map over them rather than hand-writing each repeated block.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetsx
| 1 | <Button icon={<Time />} text="Siste" /> |
| 2 | <Button icon={<Plus />} text="Ny" /> |
| 3 | <Button icon={<Fire />} text="Hot" /> |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | // config/threadButtons.ts |
| 2 | export const threadButtons = [ |
| 3 | { icon: <Time />, text: ButtonType.Siste }, |
| 4 | { icon: <Plus />, text: ButtonType.Ny }, |
| 5 | { icon: <Fire />, text: ButtonType.Hot }, |
| 6 | ]; |
| 7 | // component |
| 8 | {threadButtons.map(({ icon, text }) => <Button key={text} icon={icon} text={text} />)} |
Explanation (EN)
Objašnjenje (HR)