fix: infinity and NaN errors when no blocks are existant

This commit is contained in:
trafficlunar 2024-12-20 22:49:23 +00:00
parent 38bf1cd85c
commit 15e10334dc

View file

@ -98,10 +98,13 @@ function Canvas() {
break;
}
case "eraser":
// Fixes Infinity and NaN errors
if (blocks.length == 1) break;
setBlocks(updatedBlocks);
break;
}
}, [tool, mouseCoords, selectedBlock, updatedBlocks, setBlocks]);
}, [tool, mouseCoords, selectedBlock, updatedBlocks, setBlocks, blocks.length]);
const onMouseMove = useCallback(
(e: React.MouseEvent) => {