@tremendous/help
    Preparing search index...

    Function useDebounce

    • Custom hook that debounces a value by a specified delay.

      This hook takes a value and a delay, and returns a debounced version of the value. The debounced value only updates after the specified delay has passed without changes to the input value.

      Type Parameters

      • T

      Parameters

      • value: T

        The value to be debounced.

      • delay: number

        The delay in milliseconds for debouncing.

      Returns T

      • The debounced value.
      const [searchTerm, setSearchTerm] = useState('');
      const debouncedSearchTerm = useDebounce(searchTerm, 500);

      useEffect(() => {
      if (debouncedSearchTerm) {
      // Perform search operation
      console.log('Searching for:', debouncedSearchTerm);
      }
      }, [debouncedSearchTerm]);