typescript JSX 元素类型没有任何构造或调用签名
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37675920/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JSX element type does not have any construct or call signatures
提问by Richard
回答by Richard
This hacky typecast makes the error go away, though I don't understand it at all:
这个 hacky typecast 使错误消失了,尽管我根本不明白:
const App: any = require('./components/views/app/app');
const App: any = require('./components/views/app/app');
回答by vorillaz
How about:
怎么样:
class App extends React.Component<any, any> {
render() {
return <div>foo</div>;
}
}
回答by Michael Frost Billing
React expects a React.StatelessComponent from the imported App in mainScreenHelper.tsx This means that you need to provide that interface in App
React 期望从 mainScreenHelper.tsx 中导入的 App 中获得 React.StatelessComponent 这意味着您需要在 App 中提供该接口
interface IProps {}
const App : React.StatelessComponent<IProps> = () => (
<div></div>
);