在不匹配的情况下路由双重渲染reactJS

routing double rendering in not matching case reactJS

大家好,我遇到了 redux 路由器问题...

我定义了那两条路线:

<Route path="/*" component={() => (<Error/>)}/>
<Route exact path="/" component={() => (<Logins foo={"test"} loginHandler={this.props.loginHandler}/>)}/>

显示两条路线...

只有在没有其他人匹配时才会显示 *

您应该使用Route-Switch 制作NoMatch 页面。像这样:

import { Switch, Route } from 'react-router'

<Switch>
  <Route exact path="/" component={() => (<Logins foo={"test"} loginHandler={this.props.loginHandler}/>)}/>
  <Route component={() => (<Error/>)}/>
</Switch>