add PDP content

Signed-off-by: Chloe <pinkcloudvnn@gmail.com>
This commit is contained in:
Chloe
2024-07-07 11:09:24 +07:00
parent fab2a5e967
commit cc2c79764d
15 changed files with 76 additions and 270 deletions

16
hooks/use-debounce.tsx Normal file
View File

@@ -0,0 +1,16 @@
import { useEffect, useRef, useState } from 'react';
export const useDebounce = (value: string, delay = 500) => {
const [debouncedValue, setDebouncedValue] = useState('');
const timerRef = useRef<ReturnType<typeof setTimeout>>();
useEffect(() => {
timerRef.current = setTimeout(() => setDebouncedValue(value), delay);
return () => {
clearTimeout(timerRef.current);
};
}, [value, delay]);
return debouncedValue;
};