From 6ed2c87c4934bff65b6989900c2ec0e468d2513f Mon Sep 17 00:00:00 2001 From: keyan Date: Mon, 12 Jun 2023 17:59:53 -0500 Subject: [PATCH] fix ssr and client side rendering difference warnings --- components/header.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/components/header.js b/components/header.js index 64a7297d..3e0dd8af 100644 --- a/components/header.js +++ b/components/header.js @@ -29,9 +29,15 @@ function WalletSummary ({ me }) { function Back () { const router = useRouter() - if (typeof window !== 'undefined' && router.asPath !== '/' && - (typeof window.navigation === 'undefined' || window.navigation.canGoBack === undefined || window?.navigation.canGoBack)) { - return router.back()}> + const [show, setShow] = useState() + + useEffect(() => { + setShow(typeof window !== 'undefined' && router.asPath !== '/' && + (typeof window.navigation === 'undefined' || window.navigation.canGoBack === undefined || window?.navigation.canGoBack)) + }, [router.asPath]) + + if (show) { + return router.back()}> } return null }