Import'd React.Component not rendering with Typescript

In App.tsx I import CounterComponent.tsx, import works if CounterComponent exports function but not React class.

Here's a commit if you want to clone / reproduce: https://github.com/Falieson/react15-meteor1.5/commit/d06ebc80c4b75850338c9a2cf11cf3ec49cafa40

Thank you for your help

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

      

+3


source to share


1 answer


In React you should use <Element />

if you want to render some element. So change

const App = (
  <div className='app-container'>
    {Counter}
  </div>
)

      



to

const App = (
  <div className='app-container'>
    <Counter/>
  </div>
)

      

+3


source







All Articles