fix: monaco theme lost if re-render

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2023-04-14 00:07:28 +08:00
parent f4956ea294
commit 9a25ebc628
+7 -1
View File
@@ -1,7 +1,13 @@
import Editor, { EditorProps } from "@monaco-editor/react"
import { useMonacoTheme } from "./use-theme"
import { useMediaStore } from "~/hooks/useDarkMode"
export function MonacoEditor(props: EditorProps) {
useMonacoTheme()
return <Editor {...props} />
const isDark = useMediaStore((state) => state.isDark)
return (
// define initial theme
<Editor {...props} theme={props.theme ?? (isDark ? "dark" : "light")} />
)
}