Review: Approve

Added one comment, looks good otherwise.

Diff comments:

> diff --git a/frontend/src/hooks/useDebouncedValue.ts 
> b/frontend/src/hooks/useDebouncedValue.ts
> new file mode 100644
> index 0000000..4140266
> --- /dev/null
> +++ b/frontend/src/hooks/useDebouncedValue.ts
> @@ -0,0 +1,18 @@
> +import { useEffect, useState } from "react";
> +
> +export const DEFAULT_DELAY = 500;

This looks like it would be used in this file alone, we could either remove the 
export statement or have it placed in a more general constants file

> +
> +function useDebouncedValue<T>(value: T, delay = DEFAULT_DELAY): T {
> +  const [debouncedValue, setDebouncedValue] = useState<T>(value);
> +
> +  useEffect(() => {
> +    const timeoutId = setTimeout(() => setDebouncedValue(value), delay);
> +    return () => {
> +      clearTimeout(timeoutId);
> +    };
> +  }, [value, delay]);
> +
> +  return debouncedValue;
> +}
> +
> +export default useDebouncedValue;


-- 
https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/438880
Your team MAAS Committers is subscribed to branch 
~petermakowski/maas-site-manager:debounce-search-requests-MAASENG-1481.


-- 
Mailing list: https://launchpad.net/~sts-sponsors
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~sts-sponsors
More help   : https://help.launchpad.net/ListHelp

Reply via email to