在重写es6语法中的某些组件时,我的React路由器开始抛出以下错误:
Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in. Check the render method of `Navicon`.
如果我在Navicon组件中包含<Link>
组件,则此错误才会出现,如下所示:
import React from 'react';
import Link from 'react-router';
import './navicon.css';
class Navicon extends React.Component {
constructor(props) {
super(props)
}
render() {
return (
<div className='navicon-container' tabIndex='0'>
<div className={'dropdown'}>
<Link to={'/'}>Hello</Link>
</div>
</div>
)
}
}
export default Navicon;
安装我的路由器的组件如下所示:
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, browserHistory, IndexRoute } from 'react-router';
import App from './components/App';
import Home from './components/Home';
import About from './components/About';
import './main.css';
ReactDOM.render(
<Router history={browserHistory}>
<Route component={App}>
<Route path='/' component={Home} />
<Route path='/about' component={About} />
</Route>
</Router>,
document.getElementById('app')
);
我正在使用"react-router": "^3.0.2"
有没有人知道可能会绊倒这个错误?我使用React.createClass()
时这个错误从未出现过,所以我很困惑。
答案 0 :(得分:0)
啊,似乎由于反应路由器组件上的导出语法,显然必须使用:
Source <- c(1, 1, 2)
Target <- c(2, 3, 3)
NetworkData <- data.frame(Source, Target)
simpleNetwork(NetworkData)
这一小改变可以解决错误。