Skip to content

Commit

Permalink
bug(deployment): fix deployment issue where code invovling window s…
Browse files Browse the repository at this point in the history
…hould only run in browser

Move any `window` code into a `useEffect` in `Puzzle` component.

Co-authored-by: Erik Margetis <[email protected]>
Co-authored-by: Joseph Liang <[email protected]>
  • Loading branch information
3 people committed Apr 15, 2024
1 parent ff0e2a0 commit 4c4befc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/components/Puzzle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 (
Expand Down

0 comments on commit 4c4befc

Please sign in to comment.