260225_01_ENH: 실제 Data 통계 API와 연결 및 일부 페이지 축소
This commit is contained in:
22
src/hooks/useResize.ts
Normal file
22
src/hooks/useResize.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export const useResizeKey = (debounceMs = 150) => {
|
||||
const [key, setKey] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
let t: number | undefined;
|
||||
|
||||
const onResize = () => {
|
||||
window.clearTimeout(t);
|
||||
t = window.setTimeout(() => setKey((k) => k + 1), debounceMs);
|
||||
};
|
||||
|
||||
window.addEventListener("resize", onResize);
|
||||
return () => {
|
||||
window.removeEventListener("resize", onResize);
|
||||
window.clearTimeout(t);
|
||||
};
|
||||
}, [debounceMs]);
|
||||
|
||||
return key;
|
||||
}
|
||||
Reference in New Issue
Block a user