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
react-hooksdebouncereusereadability
Use an existing debounce hook instead of hand-rolled timers in components
For debounced effects like autosave, reuse the project's useDebounce hook (or extract one) rather than managing setTimeout/clearTimeout inline.
PR: hegnar-journalist-boost · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codetsx
| 1 | useEffect(() => { |
| 2 | const t = setTimeout(() => save(value), 800); |
| 3 | return () => clearTimeout(t); |
| 4 | }, [value]); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | const debounced = useDebounce(value, 800); |
| 2 | useEffect(() => { save(debounced); }, [debounced]); |
Explanation (EN)
Objašnjenje (HR)