Skip to content

Commit

Permalink
Fix window reference error
Browse files Browse the repository at this point in the history
  • Loading branch information
salhotra committed Jul 22, 2024
1 parent d3ea023 commit 97d45ec
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/app/components/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,18 @@ const useContainerSize = (ref: React.RefObject<HTMLDivElement>) => {

const useWindowSize = () => {
const [windowSize, setWindowSize] = useState({
width: window.innerWidth,
height: window.innerHeight,
width: 0,
height: 0,
});

useEffect(() => {
// Initial window size. This is done here instead of in the useState
// declaration because the window object is not available on the server.
setWindowSize({
width: window.innerWidth,
height: window.innerHeight,
});

const handleResize = () => {
setWindowSize({
width: window.innerWidth,
Expand Down

0 comments on commit 97d45ec

Please sign in to comment.