TypeError:React对象在createElement上未定义 [英] TypeError : React object is undefined on createElement

查看:104
本文介绍了TypeError:React对象在createElement上未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是ReactMaterial UI的新手,我正在尝试创建一个以Tabs作为子代的AppBar.我当前的实现如下所示:

I am new to React and Material UI and I am attempting to create an AppBar with Tabs as children. My current implementation looks like this:

import {React, PropTypes, Component} from 'react';
import TodoTextInput from './TodoTextInput';
import injectTapEventPlugin from 'react-tap-event-plugin';
import baseTheme from 'material-ui/styles/baseThemes/lightBaseTheme'
import getMuiTheme from 'material-ui/styles/getMuiTheme'
import {Tabs, Tab} from 'material-ui/Tabs';
import {AppBar} from 'material-ui/AppBar';

const styles = {
  headline: {
    fontSize: 24,
    paddingTop: 16,
    marginBottom: 12,
    fontWeight: 400
  }
};

function handleActive(tab) {
  alert(`A tab with this route property ${tab.props['data-route']} was activated.`);
}
const defaultStyle = {
  marginLeft: 20
};

class Header extends Component {
  render() {
    return (
      <header className="header">
      <AppBar title="TEST" />
        <Tabs>
          <Tab label="Tab 1" >
            <div>

            </div>
          </Tab>
          <Tab label="Tab 2" >
            <div>

            </div>
          </Tab>
          <Tab label="Tab 3" >
            <div>

            </div>
          </Tab>
          <Tab label="Tab 4" >
            <div>

            </div>
          </Tab>
        </Tabs>
        {children}
      </header>
    );
  }
}

module.exports = Header;

我收到一条错误消息,指出:

I'm getting an error that states:

TypeError: undefined is not an object (evaluating '_react.React.createElement')

我不确定如何解决此问题.请帮忙!

I am unsure on how to fix this problem. Please help!

推荐答案

您输入的React错误,但是您已经关闭了.更改为

You are importing React wrong, you're close though. Change it to

import React, { PropTypes, Component } from 'react';

以React为父母,以别人为孩子.您也可以只导入React并使用React.PropTypesReact.Component访问另一个.

Think of React as the parent and the others as children. You could also just import React and access the other with React.PropTypes and React.Component.

这篇关于TypeError:React对象在createElement上未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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