Skip to content

GPTVis is not a constructor #338

@gaogaomie

Description

@gaogaomie

使用官网的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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions