From 611e9e624aac5fd7698cd925814a254962b8971a Mon Sep 17 00:00:00 2001 From: "zhili.wzl" Date: Wed, 22 Sep 2021 20:53:41 +0800 Subject: [PATCH] fix(react): fix Workspace will throw error when designer is undefined --- packages/react/src/containers/Workspace.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react/src/containers/Workspace.tsx b/packages/react/src/containers/Workspace.tsx index c44b01527..1ae4c5c0f 100644 --- a/packages/react/src/containers/Workspace.tsx +++ b/packages/react/src/containers/Workspace.tsx @@ -17,9 +17,10 @@ export const Workspace: React.FC = ({ const oldId = useRef() const designer = useDesigner() const workspace = useMemo(() => { + if (!designer) return if (oldId.current && oldId.current !== id) { const old = designer.workbench.findWorkspaceById(oldId.current) - old.viewport.detachEvents() + if (old) old.viewport.detachEvents() } const workspace = { id: id || 'index',