From a691992404f01d00aeab38fdb3d7a8936801928d Mon Sep 17 00:00:00 2001 From: cfngc4594 Date: Sun, 9 Mar 2025 11:22:40 +0800 Subject: [PATCH] fix(code-editor): improve template handling and default value logic --- src/components/code-editor.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/code-editor.tsx b/src/components/code-editor.tsx index 4790bc0..c287322 100644 --- a/src/components/code-editor.tsx +++ b/src/components/code-editor.tsx @@ -66,8 +66,8 @@ export default function CodeEditor({ if (storedValue !== null) { setValue(storedValue); } else { - const template = templates.find((t) => t.language === language); - if (template) setValue(template.template); + const currentTemplate = templates.find((t) => t.language === language)?.template ?? ""; + setValue(currentTemplate); } }, [valueStorageKey, setValue, templates, language])