Skip to content

Commit

Permalink
fix: 题库编辑器闪烁修复
Browse files Browse the repository at this point in the history
  • Loading branch information
xjq committed Nov 15, 2022
1 parent 98cc113 commit 3678b04
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions client/src/pages/question/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ function Question() {
if (detail?.name) {
storage.set(
CodeStorageKey[CodeType.nodejs] + '_' + detail?.name,
getEditor()?.getValue()
editorRef.current?.getEditor()?.getValue()
);
}
};

useEffect(() => {
const editor = getEditor();
const editor = editorRef.current?.getEditor();
if (editor && detail) {
editor.setValue(
storage.get(CodeStorageKey[CodeType.nodejs] + '_' + detail?.name) ||
detail?.index
);
}
}, [getEditor, detail]);
}, [detail]);

useEffect(() => {
const editor = getEditor();
const editor = editorRef.current?.getEditor();

if (editor) {
const debounceSaveCode = debounce(saveCode, autoSaveDelay * 1000);
Expand All @@ -68,7 +68,7 @@ function Question() {
debounceSaveCode.cancel();
};
}
}, [getEditor, autoSaveDelay]);
}, [autoSaveDelay]);

useEffect(() => {
const fetchQuestion = async () => {
Expand Down

0 comments on commit 3678b04

Please sign in to comment.