mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 07:16:34 +00:00
fix(code-editor): improve template handling and default value logic
This commit is contained in:
parent
556fde6546
commit
a691992404
@ -66,8 +66,8 @@ export default function CodeEditor({
|
|||||||
if (storedValue !== null) {
|
if (storedValue !== null) {
|
||||||
setValue(storedValue);
|
setValue(storedValue);
|
||||||
} else {
|
} else {
|
||||||
const template = templates.find((t) => t.language === language);
|
const currentTemplate = templates.find((t) => t.language === language)?.template ?? "";
|
||||||
if (template) setValue(template.template);
|
setValue(currentTemplate);
|
||||||
}
|
}
|
||||||
}, [valueStorageKey, setValue, templates, language])
|
}, [valueStorageKey, setValue, templates, language])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user