solved warning
This commit is contained in:
parent
1cf062f326
commit
2c4835c04a
1 changed files with 20 additions and 17 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { useEffect, useContext, useState, useRef } from "react";
|
||||
import { useEffect, useContext, useState, useRef, useCallback } from "react";
|
||||
import { AspectRatio } from "@/components/ui/aspect-ratio";
|
||||
import OpenContext from "../Context/openContext/OpenContext";
|
||||
import CanvasContext from "../Context/canvasContext/CanvasContext";
|
||||
|
|
@ -30,7 +30,8 @@ export default function Canvas() {
|
|||
const [zoomLevel, setZoomLevel] = useState(100);
|
||||
const containerRef = useRef(null);
|
||||
|
||||
const handleZoom = (newZoom) => {
|
||||
const handleZoom = useCallback(
|
||||
(newZoom) => {
|
||||
const zoom = Math.min(Math.max(newZoom, 0), 100);
|
||||
setZoomLevel(zoom);
|
||||
|
||||
|
|
@ -48,7 +49,9 @@ export default function Canvas() {
|
|||
|
||||
canvas.renderAll();
|
||||
}
|
||||
};
|
||||
},
|
||||
[canvas, canvasRef, setCanvasHeight, setCanvasWidth]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!canvas) return;
|
||||
|
|
@ -154,7 +157,7 @@ export default function Canvas() {
|
|||
window.removeEventListener("resize", handleResize);
|
||||
}
|
||||
};
|
||||
}, [canvas, setActiveObject, zoomLevel]);
|
||||
}, [canvas, setActiveObject, zoomLevel, handleZoom]);
|
||||
|
||||
useEffect(() => {
|
||||
import("fabric").then((fabricModule) => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue