diff --git a/app/page.tsx b/app/page.tsx
index 7c780ae..edd5e06 100644
--- a/app/page.tsx
+++ b/app/page.tsx
@@ -1,10 +1,5 @@
import Canvas from "@/components/Canvas";
-import { MantineProvider } from "@mantine/core";
export default function Home() {
- return (
-
-
-
- );
+ return ;
}
diff --git a/components/Canvas.tsx b/components/Canvas.tsx
index 5b7e95e..1f3fc07 100644
--- a/components/Canvas.tsx
+++ b/components/Canvas.tsx
@@ -13,12 +13,10 @@ export default function Canvas() {
const [tool, setTool] = useState("pen");
const [lines, setLines] = useState([]);
const isDrawing = useRef(false);
- const [stageSize, setStageSize] = useState<{ width: number; height: number }>(
- {
- width: 0,
- height: 0,
- }
- );
+ const [stageSize, setStageSize] = useState<{
+ width: number;
+ height: number;
+ }>();
const handleMouseDown = (e: any) => {
isDrawing.current = true;
@@ -54,12 +52,20 @@ export default function Canvas() {
});
};
+ // Update the size on mount
+ handleResize();
+
window.addEventListener("resize", handleResize);
return () => {
window.removeEventListener("resize", handleResize);
};
}, []);
+ // component has not finished loading the window size
+ if (!stageSize) {
+ return null;
+ }
+
return (