From 1b2f76b8fa849e4d18f4adc3dbdc3599083d6b61 Mon Sep 17 00:00:00 2001 From: Cloudburst <18114966+C10udburst@users.noreply.github.com> Date: Sat, 27 Aug 2022 10:48:41 +0200 Subject: [PATCH] fix build --- gatsby-browser.js | 4 +++- src/components/compatbtn.jsx | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gatsby-browser.js b/gatsby-browser.js index a466282..1f16454 100644 --- a/gatsby-browser.js +++ b/gatsby-browser.js @@ -2,7 +2,9 @@ import { init } from '@noriginmedia/norigin-spatial-navigation'; require("prism-themes/themes/prism-dracula.min.css") -if (window !== undefined) { +const isBrowser = typeof window !== "undefined" + +if (isBrowser) { init({ visualDebug: false }); diff --git a/src/components/compatbtn.jsx b/src/components/compatbtn.jsx index 06354a0..c9ec88d 100644 --- a/src/components/compatbtn.jsx +++ b/src/components/compatbtn.jsx @@ -3,6 +3,8 @@ import { useFocusable } from '@noriginmedia/norigin-spatial-navigation'; import { Link, navigate } from "gatsby"; +const isBrowser = typeof window !== "undefined" + function CompatBtn({autoFocus, href, onClick, group, target, children, className, ...props}) { const { ref, focused, focusSelf} = useFocusable(); @@ -17,7 +19,7 @@ function CompatBtn({autoFocus, href, onClick, group, target, children, className ref.current?.focus() } - if (window) { + if (isBrowser) { window.addEventListener("keyup", (ev) => { if (!focused) return; if (document.activeElement !== ref.current) return;