Skip to content

Commit e39e2c7

Browse files
authored
docs: prevent hydration mismatch by checking isMounted before rendering dark/light mode theme toggle button (#1209)
* fix(MainLayout): prevent hydration mismatch on dark/light mode theme toggle * fix(MainLayout): prevent hydration mismatch by wrapping theme toggle icon with ClientOnly component
1 parent 78acd49 commit e39e2c7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

apps/www/.vitepress/theme/layout/MainLayout.vue

+6-4
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,12 @@ function handleSelectLink(item: NavItem) {
138138
:size="'icon'"
139139
@click="toggleDark()"
140140
>
141-
<component
142-
:is="isDark ? SunIcon : MoonIcon"
143-
class="w-4 h-4 text-foreground"
144-
/>
141+
<ClientOnly>
142+
<component
143+
:is="isDark ? SunIcon : MoonIcon"
144+
class="w-4 h-4 text-foreground"
145+
/>
146+
</ClientOnly>
145147
</Button>
146148
</nav>
147149
</div>

0 commit comments

Comments
 (0)