Skip to content

Commit

Permalink
fix: return null rather than throw an error when activeDocument gone
Browse files Browse the repository at this point in the history
avoid output errors on console
  • Loading branch information
vimcaw committed Aug 5, 2021
1 parent 37ac3dd commit 3ef9991
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Canvas/ContentContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<PixiGraphics | null>(null);
const containerRef = useCallback<RefCallback<PixiContainer>>(instance => {
canvasInstances.contentContainer = instance;
}, []);
if (!store.activeDocument) return null;

return (
<Container
Expand Down
2 changes: 1 addition & 1 deletion src/Canvas/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ settings.SCALE_MODE = SCALE_MODES.NEAREST;

export default observer(() => {
const [ref, canvasContainerRect] = useMeasure();
if (!store.activeDocument) throw new Error('Document not found');
if (!store.activeDocument) return null;

return (
<View
Expand Down

1 comment on commit 3ef9991

@vercel
Copy link

@vercel vercel bot commented on 3ef9991 Aug 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.