我试图从名为Voyager
的项目中导入名为Vega-Lite
的React类。JSX元素类型'xxx'不是JSX元素的构造函数。属性'yyy'在类型'xxx'中受到保护,但类型为'ElementClass'的公共类型为
这里是我的代码:
import * as React from 'react';
import {VegaLite} from 'datavoyager/build/components/vega-lite';
export interface Props {
spec: any;
logger: any;
}
export const View = ({spec, logger}: Props) => {
return(
<VegaLite spec={spec} logger={logger}/>
);
};
这里是我的错误:
[ts] JSX element type 'VegaLite' is not a constructor function for JSX elements. Property 'componentDidMount' is protected in type 'VegaLite' but public in type 'ElementClass'.
我知道,在课堂上Vega-Lite
,功能componentDidMount()
确实protected
。但是,我该如何解决这个错误?
PS:我已经尝试在我的tsconfig.json
中设置allowSyntheticDefaultImports
到true
,但同样的错误依然存在。
你在'tsconfig.json'中有''allowSyntheticDefaultImports':true'吗? – Andrew
@Andrew是的我试过了,但是这并没有消除错误... – CherryQu