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
reactnamingsetState
Name setState updater params meaningfully
Name the previous-state parameter in a setState updater clearly (prev/current) rather than a verbose or misleading name.
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codets
| 1 | setVote(currentParamsVote => currentParamsVote === target ? last : currentParamsVote); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | setVote(prev => prev === target ? last : prev); |
Explanation (EN)
Objašnjenje (HR)