Skip to content

Commit

Permalink
fix: ts 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
nayoonju committed Aug 13, 2024
1 parent dee63be commit 5580da4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
14 changes: 10 additions & 4 deletions hooks/useViewport.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import { useState, useEffect } from "react";

const useViewport = () => {
const [width, setWidth] = useState(window.innerWidth);
const [width, setWidth] = useState(
typeof window !== "undefined" ? window.innerWidth : 0
);

useEffect(() => {
const handleWindowResize = () => setWidth(window.innerWidth);
if (typeof window !== "undefined") {
const handleWindowResize = () => setWidth(window.innerWidth);

window.addEventListener("resize", handleWindowResize);
window.addEventListener("resize", handleWindowResize);

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

return width;
Expand Down
1 change: 0 additions & 1 deletion styles/globals.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@use "fonts";
@use "reset";
@use "variables";
@use "mixins";

0 comments on commit 5580da4

Please sign in to comment.