Redux在我的系统上正确编写了代码。但是我无法将它与React Router正确连接。这样,系统就会失败。
import React, { Component } from 'react'
import NAVBAR from './Components/Navbar'
import { BrowserRouter, Route, Switch } from 'react-router-dom'
import * as ROUTES from './constants/routes';
import SignIn from './Components/SignIn'
import SignUp from './Components/SignUp'
import Home from './Components/Home'
import Notfound from './Components/Notfound'
import { connect } from 'react-redux'
export class App extends Component {
render() {
return (
<BrowserRouter>
<div>
<NAVBAR/>
<Switch>
<Route exact path={ROUTES.HOME} component={Home} />
<Route path={ROUTES.SIGN_IN} component={SignIn} />
<Route path={ROUTES.SIGN_UP} component={SignUp} />
<Route path={ROUTES.SIGN_OUT} render={this.props.onUserOut} /> // this problem*emphasized text*
<Route component={Notfound} />
</Switch>
</div>
</BrowserRouter>
)
}
}
const mapDispatchToProps = () => {
return{
onUserOut: () => ({type:'USER_OUT'})
}
}
export default connect(null, mapDispatchToProps )(App)
Redux在我的系统上正确编写了代码。但是我无法将它与React Router正确连接。这样,系统就会失败。