We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bf7fe28 commit 8ea32abCopy full SHA for 8ea32ab
src/components/molecules/LocalizedLink/LocalizedLink.tsx
@@ -1,7 +1,7 @@
1
"use client"
2
3
import Link from "next/link"
4
-import { useParams } from "next/navigation"
+import { useParams, usePathname } from "next/navigation"
5
import React, { MouseEventHandler } from "react"
6
7
/**
@@ -20,7 +20,10 @@ const LocalizedClientLink = ({
20
passHref?: true
21
[x: string]: any
22
}) => {
23
- const { locale } = useParams()
+ const params = useParams()
24
+ const pathname = usePathname()
25
+
26
+ const locale = params?.locale || pathname?.split('/')[1] || 'en'
27
28
return (
29
<Link href={`/${locale}${href}`} {...props}>
0 commit comments