Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
diogogmatos committed Sep 28, 2023
1 parent 091e90a commit 4138265
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,21 @@ export default function RootLayout({
}: {
children: React.ReactNode;
}) {
const [width, setWidth] = useState<number>(0);
const [height, setHeight] = useState<number>(0);
const [width, setWidth] = useState<number>(window.innerWidth);
const [height, setHeight] = useState<number>(window.innerHeight);

// "Listens" for changes in the window size and updates the nr of lines accordingly
useEffect(() => {
setWidth(window.innerWidth);
setHeight(window.innerHeight);
const handleResize = () => {
setWidth(window.innerWidth);
setHeight(window.innerHeight);
};

window.addEventListener("resize", handleResize);

return () => {
window.removeEventListener("resize", handleResize);
};
}, []);

return (
Expand Down

0 comments on commit 4138265

Please sign in to comment.