From 4c4befcda5cae39456a8be10558248532239fab4 Mon Sep 17 00:00:00 2001 From: Alex Sklar Date: Mon, 15 Apr 2024 11:22:48 -0700 Subject: [PATCH] bug(deployment): fix deployment issue where code invovling `window` should only run in browser Move any `window` code into a `useEffect` in `Puzzle` component. Co-authored-by: Erik Margetis Co-authored-by: Joseph Liang --- src/components/Puzzle/index.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/Puzzle/index.js b/src/components/Puzzle/index.js index 7c57f62..f54eb83 100644 --- a/src/components/Puzzle/index.js +++ b/src/components/Puzzle/index.js @@ -2,7 +2,7 @@ import useDocusaurusContext from '@docusaurus/useDocusaurusContext' import ClientWindow from '/landing/Client-window2.svg' import Signal from './Signal' import SignalVertical from './SignalVertical' -import { useState } from 'react' +import { useEffect, useState } from 'react' function IFrame() { const { @@ -20,9 +20,12 @@ function IFrame() { } export default function Puzzle() { - const [windowWidth, setWindowWidth] = useState(window.innerWidth) + const [windowWidth, setWindowWidth] = useState() - window.addEventListener('resize', e => setWindowWidth(e.target.innerWidth)) + useEffect(() => { + setWindowWidth(window.innerWidth) + window.addEventListener('resize', e => setWindowWidth(e.target.innerWidth)) + }, []) if (windowWidth < 1094) { return (