fix: monaco theme lost if re-render
Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
parent
f4956ea294
commit
9a25ebc628
|
|
@ -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")} />
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue