From 78e50be2f73648367d0433da5cd5e0a8df399465 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Sun, 19 Nov 2023 05:49:35 +0100 Subject: [PATCH] Fix document not defined --- components/switch-account.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/switch-account.js b/components/switch-account.js index 9615920e..409d181b 100644 --- a/components/switch-account.js +++ b/components/switch-account.js @@ -5,6 +5,7 @@ import cookie from 'cookie' import { useMe, useMeRefresh } from './me' import Image from 'react-bootstrap/Image' import Link from 'next/link' +import { SSR } from '../lib/constants' const AccountContext = createContext() @@ -35,10 +36,12 @@ export const AccountProvider = ({ children }) => { }, [setAccounts]) const isAnon = useMemo(() => { + // document not defined on server + if (SSR) return false const { 'multi_auth.user-id': multiAuthUserIdCookie } = cookie.parse(document.cookie) if (!multiAuthUserIdCookie) return false return multiAuthUserIdCookie === 'anonymous' - }, [document.cookie]) + }, [accounts]) return {children} }