From 3ef999181e5f75012a372cc73782ae0e8e7bfc33 Mon Sep 17 00:00:00 2001 From: vimcaw Date: Thu, 5 Aug 2021 23:17:31 +0800 Subject: [PATCH] fix: return null rather than throw an error when activeDocument gone avoid output errors on console --- src/Canvas/ContentContainer.tsx | 2 +- src/Canvas/index.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Canvas/ContentContainer.tsx b/src/Canvas/ContentContainer.tsx index c90fe459..d4d3a3ee 100644 --- a/src/Canvas/ContentContainer.tsx +++ b/src/Canvas/ContentContainer.tsx @@ -6,11 +6,11 @@ import store from '@store'; import canvasInstances from '@utils/canvasInstances'; export default observer(({ children }: { children?: ReactNode }) => { - if (!store.activeDocument) throw new Error(); const [mask, maskRef] = useState(null); const containerRef = useCallback>(instance => { canvasInstances.contentContainer = instance; }, []); + if (!store.activeDocument) return null; return ( { const [ref, canvasContainerRect] = useMeasure(); - if (!store.activeDocument) throw new Error('Document not found'); + if (!store.activeDocument) return null; return (