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
reactperformanceuseMemoreact-hook-form
Memoize objects passed to libraries that compare props by reference
When a library re-registers behaviour based on reference identity (e.g. RHF validate rules), wrap the object in useMemo so it's stable across renders.
PR: vinify-frontend · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codetsx
| 1 | const validate = { required: v => ..., tooShort: v => ... }; // new object every render |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | const validate = useMemo(() => ({ required: v => ..., tooShort: v => ... }), [index]); |
Explanation (EN)
Objašnjenje (HR)