File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,12 @@ export const LanguagePicker = ({ variant }: Props) => {
1414 const langs = Object . values ( languages )
1515 const selectedLang = languages [ locale ]
1616
17+ // The `router.asPath` will always be without a hash in SSR
18+ // So to avoid a hydraration failure on the client, we have to
19+ // normalize it to be without the hash. That way the path is treated
20+ // in a "denormalized" way.
21+ const routerPath = router . asPath . split ( '#' ) [ 0 ]
22+
1723 return (
1824 < Picker
1925 variant = { variant }
@@ -25,7 +31,7 @@ export const LanguagePicker = ({ variant }: Props) => {
2531 text : lang . nativeName || lang . name ,
2632 selected : lang === selectedLang ,
2733 item : (
28- < Link href = { router . asPath } locale = { lang . code } >
34+ < Link href = { routerPath } locale = { lang . code } >
2935 { lang . nativeName ? (
3036 < >
3137 < span lang = { lang . code } > { lang . nativeName } </ span > (
You can’t perform that action at this time.
0 commit comments