From b27cd5017a83820748ba3bd5ee4c34c41e4d1dd7 Mon Sep 17 00:00:00 2001 From: Stephen Gordon Date: Tue, 26 Mar 2024 11:14:41 +0000 Subject: [PATCH] fixed react rerender bug when navigating home --- src/app/@auth/(.)payee/page.tsx | 13 ++++++++----- src/app/components/CreditCard/CreditCard.tsx | 11 ++++++++--- src/app/components/Layouts/SheetLayout.tsx | 5 +---- src/app/home/page.tsx | 6 +++--- src/app/layout.tsx | 13 ++++--------- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/app/@auth/(.)payee/page.tsx b/src/app/@auth/(.)payee/page.tsx index 895bdda..bf79d9d 100644 --- a/src/app/@auth/(.)payee/page.tsx +++ b/src/app/@auth/(.)payee/page.tsx @@ -123,11 +123,14 @@ export default function Page() { > -

- -

+ + {payeeAddress && useFindPayeeName(payeeAddress)} +
diff --git a/src/app/components/CreditCard/CreditCard.tsx b/src/app/components/CreditCard/CreditCard.tsx index 2afba8d..57fef12 100644 --- a/src/app/components/CreditCard/CreditCard.tsx +++ b/src/app/components/CreditCard/CreditCard.tsx @@ -4,10 +4,13 @@ import { HoverBorderGradient } from "../ui/hover-border-gradient"; import { TextGenerateEffect } from "../ui/text-generate-effect"; import truncateEthAddress from "truncate-eth-address"; import { motion } from "framer-motion"; +import { usePrivySmartAccount } from "@zerodev/privy"; export default function CreditCard() { const address = useGetAddress(); + const {user } = usePrivySmartAccount() + return ( <> @@ -24,11 +26,14 @@ export default function CreditCard() { <> -
+
-
+
+ {user?.google?.name} +
+
{truncateEthAddress(address as string)}
diff --git a/src/app/components/Layouts/SheetLayout.tsx b/src/app/components/Layouts/SheetLayout.tsx index 4593e78..02b204a 100644 --- a/src/app/components/Layouts/SheetLayout.tsx +++ b/src/app/components/Layouts/SheetLayout.tsx @@ -45,10 +45,7 @@ const SheetLayout = ({ children }) => { */} { - router.replace('/home'); - dispatch(setSheet(false)); - }} + onClose={() => dispatch(setSheet(false))} open={isOpen} > diff --git a/src/app/home/page.tsx b/src/app/home/page.tsx index a67a14f..9e29cd8 100644 --- a/src/app/home/page.tsx +++ b/src/app/home/page.tsx @@ -61,14 +61,14 @@ export default function Page() { // pathname use effect - useEffect(() => { - if (pathname === '/home') { + /* useEffect(() => { + if (pathname == '/home') { dispatch(setSheet(false)); } console.log(`Route changed to: ${pathname}`); console.log("MY ADDRESS IS", address) }, [pathname]); - + */ diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 87fd653..f6c4179 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -48,15 +48,10 @@ export default function RootLayout({ const queryClient = new QueryClient(); const router = useRouter(); - const [isInstalled, setIsInstalled] = useState(null); - const [showNav, setShowNav] = useState(true); - const pathname = usePathname(); - useEffect(() => {}) - /* useEffect(() => { @@ -184,20 +179,20 @@ export default function RootLayout({ - +
{auth}
{drawer}
{children}
- +