feat: auto proxy layout column
This commit is contained in:
16
src/components/proxy/use-window-width.ts
Normal file
16
src/components/proxy/use-window-width.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export const useWindowWidth = () => {
|
||||
const [width, setWidth] = useState(() => document.body.clientWidth);
|
||||
|
||||
useEffect(() => {
|
||||
const handleResize = () => setWidth(document.body.clientWidth);
|
||||
|
||||
window.addEventListener("resize", handleResize);
|
||||
return () => {
|
||||
window.removeEventListener("resize", handleResize);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return { width };
|
||||
};
|
||||
Reference in New Issue
Block a user