Skip to content

Commit 582209e

Browse files
xx-yokefu050409
andauthored
fix: fix isDark problem (#70)
Co-authored-by: 苏向夜 <[email protected]>
1 parent dd59be5 commit 582209e

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

src/bubble/hooks.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,12 @@ export const useTheme = () => {
1515
attributeFilter: ["class"],
1616
});
1717

18-
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
19-
const handleSystemThemeChange = (event: MediaQueryListEvent) => {
20-
setDark(event.matches);
21-
};
22-
mediaQuery.addEventListener("change", handleSystemThemeChange);
23-
2418
return () => {
2519
observer.disconnect();
26-
mediaQuery.removeEventListener("change", handleSystemThemeChange);
2720
};
2821
}, []);
2922

23+
console.log(isDark);
24+
3025
return { isDark };
3126
};

src/bubble/markdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function CodeBlock({
3737
ref: _ref,
3838
...rest
3939
}: CodeBlockProps) {
40-
const isDark = useTheme();
40+
const { isDark } = useTheme();
4141
const match = /language-(\w+)/.exec(className || "");
4242

4343
const [copied, setCopied] = useState<boolean>(false);

0 commit comments

Comments
 (0)