feat: add cache, fix ui
This commit is contained in:
@@ -16,7 +16,6 @@ export function useContacts() {
|
||||
return {
|
||||
...res,
|
||||
findById(id: ContactDTO["id"]) {
|
||||
if (!id) return null;
|
||||
return res.data?.find((i) => getId(i.id) === getId(id));
|
||||
},
|
||||
};
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { useRef } from "react";
|
||||
|
||||
export function useDebounceFn(delay: number = 500) {
|
||||
const timeoutRef = useRef<any>(null);
|
||||
|
||||
return (fn: any, delay2?: number) => {
|
||||
clearTimeout(timeoutRef.current);
|
||||
timeoutRef.current = setTimeout(fn, delay2 || delay);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user