Skip to content

Commit 738daa1

Browse files
committed
fix: hydration issue
1 parent 14340b4 commit 738daa1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

components/layout/search-toggle.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
"use client";
2+
23
import { useSearchContext } from "fumadocs-ui/contexts/search";
34
import { shortcutLabel } from "lib/utils/is-mac-like";
45
import { Search, SearchIcon } from "lucide-react";
5-
import type { ComponentProps } from "react";
6+
import { useEffect, useState, type ComponentProps } from "react";
67

78
export function SearchToggle(props: ComponentProps<"div">) {
89
const { enabled, setOpenSearch } = useSearchContext();
10+
const [shortcut, setShortcut] = useState(" ");
11+
12+
useEffect(() =>{
13+
setShortcut(shortcutLabel())
14+
}, [])
15+
916
if (!enabled) return;
1017

1118
return (
@@ -34,7 +41,7 @@ export function SearchToggle(props: ComponentProps<"div">) {
3441
</div>
3542
<div className="px-1.5 py-[3px] bg-muted rounded-xs outline outline-[0.50px] outline-offset-[-0.50px] outline-zinc-800 inline-flex justify-center items-center">
3643
<div className="text-center justify-center text-zinc-500 text-xs font-normal font-mono leading-none group-hover:text-primary">
37-
{shortcutLabel() || " "}
44+
{shortcut}
3845
</div>
3946
</div>
4047
</div>

0 commit comments

Comments
 (0)