这是错误???
我得到旧的工作代码安装新版本的libs,我看到了这个错误。但我无法理解它的含义。
//index.js
import React from 'react'
import {render} from 'react-dom'
import { BrowserRouter as Router } from 'react-router-dom'
import {Provider} from 'react-redux'
import configureStore, {history} from './store/configureStore'
import {routes} from './routes'
import { ConnectedRouter, routerMiddleware, push } from 'react-router-redux'
const store = configureStore();
render(
<Provider store={store}>
<Router history={history} routes={routes}/>
</Provider>,
document.getElementById('app')
);
//routes.js
import React from 'react'
import {Route} from 'react-router-dom'
import App from './containers/App'
export const routes = (
<div>
<Route path='/' component={App} />
</div>
);
//App.js
import React, {Component} from 'react'
import NavLink from '../../components/NavLink'
export default class App extends Component {
render() {
return (
<div className='container'>
<ul className='nav nav-pills'>
<li>
<NavLink onlyActiveOnIndex={true} to='/'>Главная</NavLink>
</li>
</ul>
{this.props.children}
</div>
)
}
}
这是什么错误?我的代码有什么问题? 安装react-router-dom@^4.1.0:
答案 0 :(得分:1)
只是强迫它成为一个函数,因为道具期望它摆脱控制台错误,即使这不是理想的解决方案。
<Route path='/' component={props => <App {...props} />} />
https://github.com/ReactTraining/react-router/issues/6420#issuecomment-433541079