Compare commits

...

1 Commits

Author SHA1 Message Date
Felix Roos 070b4364fe fix: codemirror does not vanish anymore on hot reload 2024-01-12 19:31:10 +01:00
2 changed files with 12 additions and 1 deletions
+1
View File
@@ -323,6 +323,7 @@ export class StrudelMirror {
this.editor.dispatch({ changes });
}
clear() {
this.stop();
this.onStartRepl && document.removeEventListener('start-repl', this.onStartRepl);
}
}
+11 -1
View File
@@ -100,6 +100,16 @@ export function Repl({ embedded = false }) {
});
editorRef.current = editor;
if (import.meta.hot) {
import.meta.hot.dispose(() => {
editorRef.current.clear();
setTimeout(() => {
delete editorRef.current;
delete containerRef.current;
});
});
}
}, []);
const [replState, setReplState] = useState({});
@@ -199,7 +209,7 @@ export function Repl({ embedded = false }) {
id="code"
ref={(el) => {
containerRef.current = el;
if (!editorRef.current) {
if (!editorRef.current && containerRef.current) {
init();
}
}}