Skip to content

Commit

Permalink
fixed react rerender bug when navigating home
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen-Gordon committed Mar 26, 2024
1 parent 922dde7 commit b27cd50
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
13 changes: 8 additions & 5 deletions src/app/@auth/(.)payee/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,14 @@ export default function Page() {
>
<BackButton />
</div>
<p className='text-center'>
<TextGenerateEffect
words={`${payeeAddress && useFindPayeeName(payeeAddress)} ` as string}
/>
</p>
<motion.p
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
transition={{ duration: 1 }}
className='font-inherit text-center leading-snug tracking-wide text-inherit mix-blend-exclusion'
>
{payeeAddress && useFindPayeeName(payeeAddress)}
</motion.p>
<div className='ml-auto'>
<Avatar className='h-9 w-9 bg-white'></Avatar>
</div>
Expand Down
11 changes: 8 additions & 3 deletions src/app/components/CreditCard/CreditCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
<motion.div
Expand All @@ -16,19 +19,21 @@ export default function CreditCard() {
}}
transition={{
duration: 0.3,

}}
>
<HoverBorderGradient className='relative grid h-52 w-full rounded-xl shadow-lg'>
<div className='absolute -z-50 h-full w-full rounded-xl bg-transparent bg-gradient-to-tr from-slate-50/10 backdrop-blur-xl'>
<></>
</div>

<div className='absolute z-50 grid h-full w-full content-center items-center justify-center p-2 text-center text-5xl text-black/80 mix-blend-exclusion dark:text-white/80'>
<div className='absolute z-50 grid h-full w-full content-center items-center justify-center p-2 text-center text-5xl text-card-foreground mix-blend-exclusion '>
<TextGenerateEffect words='$56'></TextGenerateEffect>
</div>
<div className='absolute z-50 mb-auto grid h-full w-full content-end p-4'>
<div className='absolute z-50 mb-auto flex h-full w-full content-end justify-between p-4'>
<div className='text-muted-foreground mb-auto grid h-full content-end justify-start text-base mix-blend-exclusion'>
{user?.google?.name}
</div>
<div className='text-muted-foreground mb-auto grid h-full content-end justify-start text-right text-base mix-blend-exclusion'>
{truncateEthAddress(address as string)}
</div>
</div>
Expand Down
5 changes: 1 addition & 4 deletions src/app/components/Layouts/SheetLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ const SheetLayout = ({ children }) => {
</Sheet> */}
<Drawer
shouldScaleBackground={true}
onClose={() => {
router.replace('/home');
dispatch(setSheet(false));
}}
onClose={() => dispatch(setSheet(false))}
open={isOpen}
>
<DrawerOverlay />
Expand Down
6 changes: 3 additions & 3 deletions src/app/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

*/



Expand Down
13 changes: 4 additions & 9 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,10 @@ export default function RootLayout({
const queryClient = new QueryClient();
const router = useRouter();

const [isInstalled, setIsInstalled] = useState<boolean | null>(null);

const [showNav, setShowNav] = useState<boolean>(true);

const pathname = usePathname();


useEffect(() => {})

/*
useEffect(() => {
Expand Down Expand Up @@ -184,20 +179,20 @@ export default function RootLayout({
<QueryClientProvider client={queryClient}>
<AnimatePresence mode='wait' initial={false}>
<LayoutGroup>

<div vaul-drawer-wrapper=''
className='h-[100vh] text-gray-300'>
<div>{auth}</div>
<div>{drawer}</div>

<main
vaul-drawer-wrapper=''
className='h-[100vh] text-gray-300'

>
{children}
</main>
<div className='w-full overflow-hidden'>
<BottomNavbar />
</div>

</div>
</LayoutGroup>
</AnimatePresence>
</QueryClientProvider>
Expand Down

0 comments on commit b27cd50

Please sign in to comment.