From 21595b9c830b00bff424ddd45d7b77fddc4e9315 Mon Sep 17 00:00:00 2001 From: fantasticit Date: Mon, 23 May 2022 14:27:50 +0800 Subject: [PATCH] fix #56 --- packages/client/src/components/template/editor/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/client/src/components/template/editor/index.tsx b/packages/client/src/components/template/editor/index.tsx index f2cc8bef..4ffdcd06 100644 --- a/packages/client/src/components/template/editor/index.tsx +++ b/packages/client/src/components/template/editor/index.tsx @@ -25,9 +25,8 @@ const { Text } = Typography; export const TemplateEditor: React.FC = ({ templateId }) => { const { user } = useUser(); const { data, loading, error, updateTemplate, deleteTemplate } = useTemplate(templateId); - const { width: windowWidth } = useWindowSize(); - const [title, setTitle] = useState(data.title); + const [title, setTitle] = useState(data && data.title); const [isPublic, setPublic] = useState(false); const { width, fontSize } = useDocumentStyle(); const editorWrapClassNames = useMemo(() => { @@ -47,6 +46,7 @@ export const TemplateEditor: React.FC = ({ templateId }) => { useEffect(() => { if (!data) return; setPublic(data.isPublic); + setTitle(data.title); }, [data]); return (