-
Notifications
You must be signed in to change notification settings - Fork 229
Open
Labels
Description
- OS: macOS 15.6.1 (24G90)
- Browser chrome
- Version @antv/g@6.1.28 、@antv/g-webgl@2.0.52
Steps To Reproduce
- 初始化一个画布
- 创建一个圆
- 把圆添加进画布
import { Canvas, CanvasEvent, Circle } from "@antv/g";
import { Renderer } from "@antv/g-webgl";
import { useEffect, useRef } from "react";
export function Test() {
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
if (!ref.current) return;
const renderer = new Renderer();
const canvas = new Canvas({
container: ref.current,
width: 600,
height: 500,
renderer,
});
const circle = new Circle({
style: {
r: 50,
fill: "#1890FF",
stroke: "#F04864",
lineWidth: 4,
cursor: "pointer",
},
});
const fn = () => {
canvas.appendChild(circle);
};
canvas.addEventListener(CanvasEvent.READY, fn);
return () => {
canvas.removeEventListener(CanvasEvent.READY, fn);
canvas.destroy();
};
}, []);
return <div ref={ref}></div>;
}如果关闭react的严格模式不会报错,打开会报错,
报错信息如下:
Error handled by React Router default ErrorBoundary: TypeError: Cannot read properties of undefined (reading 'destroy')
at RenderGraphPlugin.ts:277:19
at SyncHook.ts:15:16
at Array.forEach ()
at SyncHook2.call (SyncHook.ts:13:20)
at RenderingService2.destroy (RenderingService.ts:332:24)
at Canvas2.destroy (Canvas.ts:387:32)
at cleanExistedCanvas (canvas.ts:18:52)
at new Canvas2 (Canvas.ts:198:7)
at index.tsx?t=1761104888817:12:24
at Object.react_stack_bottom_frame (react-dom-client.development.js:25989:20)
Reactions are currently unavailable