-
Notifications
You must be signed in to change notification settings - Fork 82
Description
使用官网的react示例代码,报错 GPTVis is not a constructor
【示例代码】
import { GPTVis } from "@antv/gpt-vis";
import { useEffect, useRef } from "react";
function ChartComponent({ visSyntax }) {
const containerRef = useRef();
const gptVisRef = useRef();
useEffect(() => {
gptVisRef.current = new GPTVis({
container: containerRef.current,
width: 600,
height: 400,
});
return () => gptVisRef.current?.destroy();
}, []);
useEffect(() => {
if (gptVisRef.current && visSyntax) {
gptVisRef.current.render(visSyntax);
}
}, [visSyntax]);
return
}
export default ChartComponent;
【报错如下】
Uncaught TypeError: GPTVis is not a constructor
at Chart.tsx:9:25
at commitHookEffectListMount (react-dom.development.js:23189:26)
at commitPassiveMountOnFiber (react-dom.development.js:24965:13)
at commitPassiveMountEffects_complete (react-dom.development.js:24930:9)
at commitPassiveMountEffects_begin (react-dom.development.js:24917:7)
at commitPassiveMountEffects (react-dom.development.js:24905:3)
at flushPassiveEffectsImpl (react-dom.development.js:27078:3)
at flushPassiveEffects (react-dom.development.js:27023:14)
at react-dom.development.js:26808:9
at workLoop (scheduler.development.js:266:34)