Skip to content

Commit

Permalink
fix(react): fix Workspace will throw error when designer is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang committed Sep 22, 2021
1 parent 3797b4b commit 611e9e6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/react/src/containers/Workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ export const Workspace: React.FC<IWorkspaceProps> = ({
const oldId = useRef<string>()
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',
Expand Down

0 comments on commit 611e9e6

Please sign in to comment.