在App.tsx中我导入CounterComponent.tsx,如果CounterComponent导出函数但不导出React类,则导入有效。
如果要克隆/重现,请执行以下提交:https://github.com/Falieson/react15-meteor1.5/commit/d06ebc80c4b75850338c9a2cf11cf3ec49cafa40
感谢您的帮助
App.tsx
import * as React from 'react';
import Counter from './counter/CounterComponent'
const App = (
<div className='app-container'>
{Counter}
</div>
)
export default App
CounterComponent.tsx
import * as React from 'react'
class CounterModule extends React.Component<{}, {}> {
public render() {
return (
<div>
Counter Module Placeholder
</div>
)
}
}
export default CounterModule
答案 0 :(得分:3)
在React中,当你想渲染一些元素时,你应该使用<Element />
。所以改变
const App = (
<div className='app-container'>
{Counter}
</div>
)
到
const App = (
<div className='app-container'>
<Counter/>
</div>
)