Skip to content

Commit

Permalink
fix: parentElement不存在的情况
Browse files Browse the repository at this point in the history
  • Loading branch information
xuying.xu committed Aug 15, 2024
1 parent 8885e66 commit f603cc9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/f-react/src/createCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ const createCanvas = (CanvasClass: typeof Canvas) => {
});

const targetNode = this.canvasRef.current?.parentElement;
const { width, height } = targetNode.getBoundingClientRect();
if (targetNode) return;
const { width, height } = targetNode?.getBoundingClientRect();
this.parentNode = {
width: Math.round(width),
height: Math.round(height),
Expand All @@ -133,6 +134,7 @@ const createCanvas = (CanvasClass: typeof Canvas) => {

resize() {
const targetNode = this.canvasRef.current?.parentElement;
if (targetNode) return;
const { width, height } = targetNode.getBoundingClientRect();
const lastWidth = Math.round(width);
const lastHeight = Math.round(height);
Expand Down

0 comments on commit f603cc9

Please sign in to comment.