File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -11,9 +11,12 @@ import {
11
11
MOBILE_LANGUAGE_BUTTON_NAME ,
12
12
} from "@/lib/constants"
13
13
14
+ import { useIsClient } from "@/hooks/useIsClient"
14
15
import { useMediaQuery } from "@/hooks/useMediaQuery"
15
16
16
17
const LanguageMorpher = ( ) => {
18
+ const isClient = useIsClient ( )
19
+
17
20
const handleMobileClick = ( ) => {
18
21
; ( document . getElementById ( HAMBURGER_BUTTON_ID ) as HTMLButtonElement ) . click ( )
19
22
setTimeout (
@@ -36,10 +39,14 @@ const LanguageMorpher = () => {
36
39
37
40
const [ isLarge ] = useMediaQuery ( [ `(min-width: ${ screens . md } )` ] )
38
41
42
+ // Use fallback value during SSR to prevent hydration mismatch
43
+ // Default to false (mobile) during SSR, then use actual value on client
44
+ const isLargeScreen = isClient && isLarge
45
+
39
46
return (
40
47
< Button
41
48
className = "mx-auto w-fit text-md text-primary no-underline"
42
- onClick = { isLarge ? handleDesktopClick : handleMobileClick }
49
+ onClick = { isLargeScreen ? handleDesktopClick : handleMobileClick }
43
50
variant = "ghost"
44
51
>
45
52
< Morpher
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import { useNavigation } from "../useNavigation"
16
16
import { useThemeToggle } from "../useThemeToggle"
17
17
18
18
import { useBreakpointValue } from "@/hooks/useBreakpointValue"
19
+ import { useIsClient } from "@/hooks/useIsClient"
19
20
import { useTranslation } from "@/hooks/useTranslation"
20
21
21
22
const LazyButton = dynamic (
@@ -86,9 +87,14 @@ const ClientSideNav = () => {
86
87
const { toggleColorMode, ThemeIcon, themeIconAriaLabel } = useThemeToggle ( )
87
88
88
89
const languagePickerRef = useRef < HTMLButtonElement > ( null )
90
+ const isClient = useIsClient ( )
89
91
90
92
// avoid rendering/adding desktop Menu version to DOM on mobile
91
- const desktopScreen = useBreakpointValue ( { base : false , md : true } )
93
+ const desktopScreenValue = useBreakpointValue ( { base : false , md : true } )
94
+
95
+ // Use fallback value during SSR to prevent hydration mismatch
96
+ // Default to false (mobile) during SSR, then use actual value on client
97
+ const desktopScreen = isClient && desktopScreenValue
92
98
93
99
return (
94
100
< >
You can’t perform that action at this time.
0 commit comments