Skip to content

Commit d3ce339

Browse files
committed
replace old hooks
1 parent 686e609 commit d3ce339

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

app/[locale]/dapps/_components/dapps.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import React, {
88
useRef,
99
useState,
1010
} from "react"
11-
import { useRouter } from "next/router"
11+
import { useSearchParams } from "next/navigation"
1212
import { useLocale } from "next-intl"
1313

1414
import type { ChildOnlyProp } from "@/lib/types"
@@ -287,17 +287,16 @@ interface Categories {
287287

288288
const DappsPage = () => {
289289
const { t } = useTranslation(["page-dapps", "common"])
290-
const { query } = useRouter()
290+
const searchParams = useSearchParams()
291291
const locale = useLocale()
292292

293293
const [selectedCategory, setCategory] = useState<CategoryType>(
294294
CategoryType.FINANCE
295295
)
296296
const explore = useRef<HTMLDivElement>(null)
297297

298+
const queryParamCategories = searchParams.get("category") || ""
298299
useEffect(() => {
299-
// Fetch category on load
300-
const queryParamCategories = (query.category as string) || ""
301300
const selectedCategory = queryParamCategories
302301
? (queryParamCategories.split(",")[0] as CategoryType)
303302
: CategoryType.FINANCE // Default to finance category if empty
@@ -319,7 +318,7 @@ const DappsPage = () => {
319318
behavior: "smooth",
320319
})
321320
}
322-
}, [query.category])
321+
}, [queryParamCategories])
323322

324323
const updatePath = (
325324
selectedCategory: CategoryType,

src/components/RadialChart/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client"
22

33
import { type ReactNode, useEffect, useState } from "react"
4-
import { useRouter } from "next/router"
4+
import { useLocale } from "next-intl"
55
import { MdInfoOutline } from "react-icons/md"
66
import { PolarAngleAxis, RadialBar, RadialBarChart } from "recharts"
77

@@ -53,7 +53,7 @@ const RadialChart = ({
5353
displayValue,
5454
}: RadialChartProps) => {
5555
const { t } = useTranslation("common")
56-
const { locale } = useRouter()
56+
const locale = useLocale()
5757
const [isMounted, setIsMounted] = useState(false)
5858

5959
useEffect(() => {

src/components/Resources/useResources.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect, useState } from "react"
2-
import { useRouter } from "next/router"
2+
import { useLocale } from "next-intl"
33

44
import { Lang } from "@/lib/types"
55

@@ -60,7 +60,7 @@ const formatSmallUSD = (value: number, locale: string): string =>
6060

6161
export const useResources = ({ txCostsMedianUsd }): DashboardSection[] => {
6262
const { t } = useTranslation("page-resources")
63-
const { locale } = useRouter()
63+
const locale = useLocale()
6464
const localeForNumberFormat = getLocaleForNumberFormat(locale! as Lang)
6565

6666
const medianTxCost =

0 commit comments

Comments
 (0)