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
clean-codereacthandlersredundancy
Pass the setter directly when a wrapper handler only forwards its argument
If a handler does nothing but call a state setter with the same value, pass the setter itself instead of wrapping it.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codejavascript
| 1 | const handleSize = (s: number) => setPageSize(s); |
| 2 | <Pager onSize={handleSize} /> |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejavascript
| 1 | <Pager onSize={setPageSize} /> |
Explanation (EN)
Objašnjenje (HR)