From 884200e153e4f22d790902f7c8ec9ca5d805bc42 Mon Sep 17 00:00:00 2001 From: Lesenelir Date: Thu, 7 Mar 2024 17:33:57 +0800 Subject: [PATCH] refactor: move component definitions outside the component (#1531) --- src/app/[locale]/(home)/about/page.tsx | 25 ++++--------------------- src/components/home/EntranceButton.tsx | 18 +++++++++++------- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/src/app/[locale]/(home)/about/page.tsx b/src/app/[locale]/(home)/about/page.tsx index cdaeb7fc..98c4c239 100644 --- a/src/app/[locale]/(home)/about/page.tsx +++ b/src/app/[locale]/(home)/about/page.tsx @@ -1,10 +1,9 @@ import { getTranslations } from "next-intl/server" import Link from "next/link" -import { memo } from "react" import { Logo } from "~/components/common/Logo" import { BlockNumber } from "~/components/home/BlockNumber" -import { default as OriginEntranceButton } from "~/components/home/EntranceButton" +import { EntranceButton } from "~/components/home/EntranceButton" import { Integration } from "~/components/home/Integrations" import { ShowCase } from "~/components/home/Showcase" import { Button } from "~/components/ui/Button" @@ -12,23 +11,9 @@ import { Image } from "~/components/ui/Image" import { CSB_SCAN, GITHUB_LINK } from "~/lib/env" import { getSiteLink } from "~/lib/helpers" -async function Home() { +export default async function Home() { const t = await getTranslations() - const EntranceButton = memo(function Button() { - return ( - - - {t("Dashboard")} - - } - unconnectedContent={t("Get my xLog in 5 minutes")} - /> - ) - }) - const features: { title: string subfeatures: { @@ -181,7 +166,7 @@ async function Home() { } >
{index + 1}
@@ -325,7 +310,7 @@ async function Home() {
-
+
@@ -333,5 +318,3 @@ async function Home() {
) } - -export default Home diff --git a/src/components/home/EntranceButton.tsx b/src/components/home/EntranceButton.tsx index b606e0cb..dd41a9d7 100644 --- a/src/components/home/EntranceButton.tsx +++ b/src/components/home/EntranceButton.tsx @@ -1,5 +1,6 @@ "use client" +import { useTranslations } from "next-intl" import { useRouter } from "next/navigation" import React from "react" @@ -7,13 +8,9 @@ import { useAccountState } from "@crossbell/connect-kit" import { Button } from "~/components/ui/Button" -interface Props { - connectedContent: React.ReactNode - unconnectedContent: React.ReactNode -} - -export default function EntranceButton(props: Props) { +export function EntranceButton() { const router = useRouter() + const t = useTranslations() const isConnected = useAccountState((s) => !!s.computed.account) return ( @@ -23,7 +20,14 @@ export default function EntranceButton(props: Props) { size="2xl" variantColor="black" > - {isConnected ? props.connectedContent : props.unconnectedContent} + {isConnected ? ( + <> + + {t("Dashboard")} + + ) : ( + {t("Get my xLog in 5 minutes")} + )} ) }