TypeScript和ReactDOM.render方法不接受组件 [英] TypeScript and ReactDOM.render method doesn't accept component

查看:170
本文介绍了TypeScript和ReactDOM.render方法不接受组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用TypeScript和React.我已经定义了AppContainer.tsx组件,并将其导出为默认组件.我在文件app.ts中使用了此文件,其中ReactDOM用于将其呈现为目标dom元素.但是在那里,我收到以下错误(见图). 阅读下面的详细信息和指向GitHub存储库的链接.

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.ts where ReactDOM lives to render it to the targetted dom element. But there I receive the following errors (see image). Read below for more information and links to GitHub repo.

问题:我在做什么或在解释错误?从所有代码示例中,我已经看到这应该可行-但也许(显然)我缺少了一些东西. 以下是更多信息,并链接到完整的GitHub存储库.

Question: What am I doing, or interpreting, wrong? From all code examples I've seen this should work - but maybe (clearly) I'm missing something. Below is more info and links to the full GitHub repo.

  • react 15.4.2
  • react-dom 15.4.2
  • typings: https://github.com/aredfox/electron-starter/blob/master/typings.json
  • tsconfig: https://github.com/aredfox/electron-starter/blob/master/tsconfig.json
/// <reference path="../../../typings/index.d.ts" />

// Top level application component

/*------------------------------------------------------------------------------------*/
/** IMPORTS **/
import * as React from 'react';
import { Component } from 'react';
/*------------------------------------------------------------------------------------*/
/*///*/

/*------------------------------------------------------------------------------------*/
/** COMPONENT **/
export default class AppContainer extends React.Component<{}, {}> {    
    render() {
        return ( <div /> );
    }    
}        
/*------------------------------------------------------------------------------------*/
/*///*/

https://github.com/aredfox/electron-starter/blob/master/src/views/components/AppContainer.tsx

/// <reference path="../../typings/index.d.ts" />
/// <reference path="interfaces.d.ts" />

// Setting up react inside the host html

/*------------------------------------------------------------------------------------*/
/** IMPORTS **/
import * as React from 'react';
import * as ReactDOM from 'react-dom';
// Components
import AppContainer from './components/AppContainer';
/*------------------------------------------------------------------------------------*/
/*///*/

/*------------------------------------------------------------------------------------*/
/** RENDER TO DOM **/
ReactDOM.render(
    <AppContainer/>,
    document.getElementById('AppContainer')
);
/*------------------------------------------------------------------------------------*/
/*///*/

https://github.com/aredfox/电子启动器/blob/master/src/views/app.ts

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆