Fix: monoco editor randomly not initialise theme correctly in dark mode

This commit is contained in:
Bobby Wang
2022-09-15 01:46:10 +07:00
parent 0e98aff815
commit 3bc74e284b
2 changed files with 7 additions and 19 deletions

View File

@@ -71,25 +71,6 @@ export default function useMonacoCustomizations({
};
}, []);
// Initialize theme
useEffect(() => {
if (!monaco) {
// useMonaco returns a monaco instance but initialisation is done asynchronously
// dont execute the logic until the instance is initialised
return;
}
setTimeout(() => {
try {
monaco.editor.defineTheme("github-light", githubLightTheme as any);
monaco.editor.defineTheme("github-dark", githubDarkTheme as any);
monaco.editor.setTheme("github-" + theme.palette.mode);
} catch (error) {
console.error("Could not set Monaco theme: ", error);
}
});
}, [monaco, theme.palette.mode]);
// Initialize external libs & TypeScript compiler options
useEffect(() => {
if (!monaco) return;