pref(editor): subscribe isDark once
Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
@@ -3,8 +3,8 @@ import { useMonacoTheme } from "./use-theme"
|
||||
import { useMediaStore } from "~/hooks/useDarkMode"
|
||||
|
||||
export function MonacoEditor(props: EditorProps) {
|
||||
useMonacoTheme()
|
||||
const isDark = useMediaStore((state) => state.isDark)
|
||||
useMonacoTheme(isDark)
|
||||
|
||||
return (
|
||||
// define initial theme
|
||||
|
||||
@@ -20,10 +20,10 @@ const useDefineTheme = (theme: string, json: any) => {
|
||||
}, [monaco, theme])
|
||||
}
|
||||
|
||||
export const useMonacoTheme = () => {
|
||||
export const useMonacoTheme = (isDark: boolean) => {
|
||||
useDefineTheme("light", Light)
|
||||
useDefineTheme("dark", Dark)
|
||||
const isDark = useMediaStore((state) => state.isDark)
|
||||
|
||||
const monaco = useMonaco()
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user