Skip to content

fix: prevent workspace search bar text from getting garbled #9703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Sep 15, 2023
Prev Previous commit
docs: Add file description and warning
  • Loading branch information
Parkreiner committed Sep 15, 2023
commit 83c6022265ebdded392de04d9b7c39cc3d137c64
13 changes: 13 additions & 0 deletions site/src/hooks/debounce.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/**
* @file Defines hooks for created debounced versions of functions and arbitrary
* values.
*
* It is not safe to call a general-purpose debounce utility inside a React
* render. It will work on the initial render, but the memory reference for the
* value will change on re-renders. Most debounce functions create a "stateful"
* version of a function by leveraging closure; but by calling it repeatedly,
* you create multiple "pockets" of state, rather than a centralized one.
*
* Debounce utilities can make sense if they can be called directly outside the
* component or in a useEffect call, though.
*/
import { useCallback, useEffect, useRef, useState } from "react";

type useDebouncedFunctionReturn<Args extends unknown[]> = Readonly<{
Expand Down