gpt4 book ai didi

javascript - 类型错误 : React object is undefined on createElement

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:07:08 26 4
gpt4 key购买 nike

我是 ReactMaterial UI 的新手,我正在尝试创建一个带有 TabsAppBar 作为 children 。我当前的实现如下所示:

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;

我收到一条错误消息:

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

我不确定如何解决这个问题。请帮忙!

最佳答案

你错误地导入了 React,不过你已经接近了。改成

从 'react' 导入 React, { PropTypes, Component };

将 React 视为父项,将其他项视为子项。您也可以只导入 React 并使用 React.PropTypesReact.Component 访问另一个。

关于javascript - 类型错误 : React object is undefined on createElement,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40600763/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com