mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
added lab search
This commit is contained in:
parent
16d12f92da
commit
ddf2b6eda3
16 changed files with 149 additions and 28 deletions
12
src/hooks/data/useDebouncedValue.ts
Normal file
12
src/hooks/data/useDebouncedValue.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { useEffect, useState } from 'react';
|
||||
|
||||
export const useDebouncedValue = <T>(val: T, delay = 300) => {
|
||||
const [state, setState] = useState<T>(val);
|
||||
|
||||
useEffect(() => {
|
||||
const timeout = setTimeout(() => setState(val), delay);
|
||||
return () => clearTimeout(timeout);
|
||||
}, [val, delay]);
|
||||
|
||||
return state;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue