TypeScript and ReactDOM.render method doesn't accept component

后端 未结 1 1229
长发绾君心
长发绾君心 2021-01-04 04:30

TL;DR

I\'m using TypeScript and React. I\'ve defined my AppContainer.tsx component, exported it as default. I\'m consuming this in the file app.

1条回答
  •  抹茶落季
    2021-01-04 05:21

    You can't use jsx/tsx syntax inside files which have ts extension.

    You can either rename your file to app.tsx, or you can use React.createElement:

    ReactDOM.render(
        React.createElement(AppContainer),
        document.getElementById('AppContainer')
    );
    

    0 讨论(0)
提交回复
热议问题