Skip to content

Commit 1e056a7

Browse files
committed
Replace useRouter with usePathname for ListenToPlayer slug
1 parent 5825bda commit 1e056a7

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

src/layouts/Static.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useRouter } from "next/router"
21
import { useLocale } from "next-intl"
32
import type { HTMLAttributes } from "react"
43

@@ -89,7 +88,6 @@ export const StaticLayout = ({
8988
lastEditLocaleTimestamp,
9089
contentNotTranslated,
9190
}: StaticLayoutProps) => {
92-
const { asPath } = useRouter()
9391
const locale = useLocale()
9492
const pathname = usePathname()
9593

@@ -123,7 +121,7 @@ export const StaticLayout = ({
123121
{lastEditLocaleTimestamp}
124122
</p>
125123
)}
126-
<ListenToPlayer slug={asPath} />
124+
<ListenToPlayer slug={pathname} />
127125
</Stack>
128126
)}
129127

src/pages/[locale]/eth.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { GetStaticProps } from "next"
2-
import { useRouter } from "next/router"
32
import type { ComponentProps, HTMLAttributes } from "react"
43

54
import type { BasePageProps, ChildOnlyProp, Lang, Params } from "@/lib/types"
@@ -35,6 +34,7 @@ import { DEFAULT_LOCALE, LOCALES_CODES } from "@/lib/constants"
3534

3635
import { useTranslation } from "@/hooks/useTranslation"
3736
import loadNamespaces from "@/i18n/loadNamespaces"
37+
import { usePathname } from "@/i18n/routing"
3838
import eth from "@/public/images/eth.png"
3939
import ethCat from "@/public/images/eth-gif-cat.png"
4040
import defi from "@/public/images/finance_transparent.png"
@@ -208,7 +208,7 @@ export const getStaticProps = (async ({ params }) => {
208208

209209
const EthPage = () => {
210210
const { t } = useTranslation("page-eth")
211-
const { asPath } = useRouter()
211+
const pathname = usePathname()
212212

213213
const tokens = [
214214
{
@@ -335,7 +335,7 @@ const EthPage = () => {
335335
<GrayContainer>
336336
<Content>
337337
<div className="mb-8">
338-
<ListenToPlayer slug={asPath} />
338+
<ListenToPlayer slug={pathname} />
339339
</div>
340340
<Intro>
341341
<Text>{t("page-eth-description")} </Text>

src/pages/[locale]/wallets/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ComponentPropsWithRef } from "react"
22
import { GetStaticProps } from "next"
3-
import { useRouter } from "next/router"
3+
import { useLocale } from "next-intl"
44

55
import { BasePageProps, Lang, Params } from "@/lib/types"
66

@@ -32,6 +32,7 @@ import { DEFAULT_LOCALE, LOCALES_CODES } from "@/lib/constants"
3232

3333
import { useTranslation } from "@/hooks/useTranslation"
3434
import loadNamespaces from "@/i18n/loadNamespaces"
35+
import { usePathname } from "@/i18n/routing"
3536
import DappsImage from "@/public/images/doge-computer.png"
3637
import ETHImage from "@/public/images/eth-logo.png"
3738
import FindWalletImage from "@/public/images/wallets/find-wallet.png"
@@ -76,7 +77,8 @@ export const getStaticProps = (async ({ params }) => {
7677
}) satisfies GetStaticProps<BasePageProps, Params>
7778

7879
const WalletsPage = () => {
79-
const { locale, asPath } = useRouter()
80+
const pathname = usePathname()
81+
const locale = useLocale()
8082
const { t } = useTranslation("page-wallets")
8183

8284
const heroContent = {
@@ -227,7 +229,7 @@ const WalletsPage = () => {
227229

228230
<div className="mt-4 w-full border-t bg-background-highlight px-0 py-16 lg:mt-8">
229231
<div className="-mb-8 w-full px-8 py-4 pb-0">
230-
<ListenToPlayer slug={asPath} />
232+
<ListenToPlayer slug={pathname} />
231233
</div>
232234
<div className="w-full px-8 py-4 pb-0">
233235
<h2 className="mb-0 mt-12 text-2xl leading-[1.4] md:text-[2rem]">

src/pages/[locale]/what-is-ethereum.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { GetStaticProps, InferGetStaticPropsType } from "next"
22
import type { ImageProps } from "next/image"
3-
import { useRouter } from "next/router"
3+
import { useLocale } from "next-intl"
44
import type { HTMLAttributes } from "react"
55
import { MdInfoOutline } from "react-icons/md"
66

@@ -58,6 +58,7 @@ import { DEFAULT_LOCALE, LOCALES_CODES } from "@/lib/constants"
5858

5959
import useTranslation from "@/hooks/useTranslation"
6060
import loadNamespaces from "@/i18n/loadNamespaces"
61+
import { usePathname } from "@/i18n/routing"
6162
import { fetchGrowThePie } from "@/lib/api/fetchGrowThePie"
6263
import dogeComputerImg from "@/public/images/doge-computer.png"
6364
import ethImg from "@/public/images/eth.png"
@@ -220,7 +221,8 @@ const WhatIsEthereumPage = ({
220221
data,
221222
}: InferGetStaticPropsType<typeof getStaticProps>) => {
222223
const { t } = useTranslation(["page-what-is-ethereum", "learn-quizzes"])
223-
const { locale, asPath } = useRouter()
224+
const pathname = usePathname()
225+
const locale = useLocale()
224226
const localeForNumberFormat = getLocaleForNumberFormat(locale! as Lang)
225227

226228
const formatNumber = (
@@ -358,7 +360,7 @@ const WhatIsEthereumPage = ({
358360
<div className="w-full bg-background-highlight">
359361
<Section>
360362
<div className="mb-8">
361-
<ListenToPlayer slug={asPath} />
363+
<ListenToPlayer slug={pathname} />
362364
</div>
363365
<Stack className="gap-14">
364366
<TwoColumnContent id="summary">

0 commit comments

Comments
 (0)