fix: infinity and NaN errors when no blocks are existant
This commit is contained in:
parent
38bf1cd85c
commit
15e10334dc
1 changed files with 4 additions and 1 deletions
|
|
@ -98,10 +98,13 @@ function Canvas() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "eraser":
|
case "eraser":
|
||||||
|
// Fixes Infinity and NaN errors
|
||||||
|
if (blocks.length == 1) break;
|
||||||
|
|
||||||
setBlocks(updatedBlocks);
|
setBlocks(updatedBlocks);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}, [tool, mouseCoords, selectedBlock, updatedBlocks, setBlocks]);
|
}, [tool, mouseCoords, selectedBlock, updatedBlocks, setBlocks, blocks.length]);
|
||||||
|
|
||||||
const onMouseMove = useCallback(
|
const onMouseMove = useCallback(
|
||||||
(e: React.MouseEvent) => {
|
(e: React.MouseEvent) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue