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
reactpropscohesionhandlers
Define a handler where its dependencies live, then pass it down
If a handler depends only on values available in the parent, define it there and pass it as a prop instead of passing all the dependencies down to a child.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetsx
| 1 | // child receives everything it needs to build the handler itself |
| 2 | <DeleteOption postId={postId} isBanned={isBanned} onClose={onClose} onDelete={onDelete} /> |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | // parent owns the dependencies, builds the handler, passes it down |
| 2 | const handleDelete = () => { /* uses postId, isBanned, ... */ }; |
| 3 | <DeleteOption onClick={handleDelete} /> |
Explanation (EN)
Objašnjenje (HR)