我收到一个错误。 React.createElement:类型无效 - 需要字符串(对于内置组件(或类/函数(对于复合组件(,但得到:未定义
我正在尝试在索引中使用导入中的 riutes.js
import React from 'react';
import ReactDom from 'react-dom';
import routes from './routes.js';
import { HashRouter as Router, Route, IndexRoute } from 'react-router-dom';
const renderApp = (appRoutes) => {
ReactDom.render(appRoutes, document.getElementById('app'));
};
renderApp( routes() );
我从路线导出此路线.js
import React from 'react';
import { AppContainer } from 'react-hot-loader';
import { BrowserRouter as Router, Route, browserHistory, IndexRoute } from 'react-router-dom';
import App from './components/App';
const routes = () => (
<AppContainer>
<Router history={browserHistory} component={App}>
</Router>
</AppContainer>
);
export default routes;
你可能想调用routes
:
renderApp( routes() );