From e2743213f375b5ea90e6577838459035c96bb6f4 Mon Sep 17 00:00:00 2001 From: David Totrashvili Date: Mon, 28 Oct 2024 17:59:05 +0500 Subject: [PATCH] fix: tomo ssr issue (#264) --- src/components/common/AuthGuard/index.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/common/AuthGuard/index.tsx b/src/components/common/AuthGuard/index.tsx index eb248fd7..0a6bc3b4 100644 --- a/src/components/common/AuthGuard/index.tsx +++ b/src/components/common/AuthGuard/index.tsx @@ -1,4 +1,9 @@ -import type { PropsWithChildren, ReactNode } from "react"; +import { + useEffect, + useState, + type PropsWithChildren, + type ReactNode, +} from "react"; import { useWalletConnection } from "@/app/context/wallet/WalletConnectionProvider"; @@ -11,6 +16,11 @@ export function AuthGuard({ fallback, }: PropsWithChildren) { const { isConnected } = useWalletConnection(); + const [displayComponent, setDisplayComponent] = useState(false); - return isConnected ? children : fallback; + useEffect(() => { + setDisplayComponent(isConnected); + }, [isConnected]); + + return displayComponent ? children : fallback; }