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 ruleP1stack specificStack: react
reactperformancesearchux
Debounce search-as-you-type and reset pagination on new queries
Don't fire a request on every keystroke; debounce input and reset the page to the first when the query changes.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetsx
| 1 | onChange={(e) => fetchResults(e.target.value, page)} |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const debounced = useDebounce(query, 300); |
| 2 | useEffect(() => { |
| 3 | setPage(1); |
| 4 | fetchResults(debounced, 1); |
| 5 | }, [debounced]); |
Explanation (EN)
Objašnjenje (HR)