Feature/move list to client (#50)
This commit is contained in:
committed by
GitHub
parent
c2abdaadf2
commit
668434d246
10
apps/dashboard/src/hooks/useDebounceValue.ts
Normal file
10
apps/dashboard/src/hooks/useDebounceValue.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
export const useDebounceValue = <T>(value: T, delay: number): T => {
|
||||
const [state, setState] = useState(value);
|
||||
useEffect(() => {
|
||||
const handler = setTimeout(() => setState(value), delay);
|
||||
return () => clearTimeout(handler);
|
||||
}, [value, delay]);
|
||||
return state;
|
||||
};
|
||||
Reference in New Issue
Block a user