React router this.props.history.push ,推送位置但不渲染组件

React router this.props.history.push , pushing the location but not rendering the component

我的 app.js

里有这个
      render() {
    //isAuthticated() is async, so we block the rendering until we have the result.
    if (!this.state.authenticationChecked) return null;
    return (
      <div>
        <Switch>
          <PrivateRoute name={"dashboard"} authed={this.state.isAuthenticated} path="/dashboard" render={(props) => <Calendario {...props} logout={this.logout} />} />
          <LifeExpectancyRoute name={"life_expectancy"} path="/lifeExpectancy" render={(props) => <LifeExpectancy {...props} setYearsRedirect={this.setYearsRedirect} />} />
          <Route path="/login" render={(props) => <LoginPage login={this.login} authed={this.state.isAuthenticated} {...props} />} />
        </Switch>
      </div>
    )
  }
}

export default compose(
  withRouter,
  connect(null, mapDispatchToProps)
)(App);

A​​nt 然后我有这个函数,我在单击图标时调用它

  logout = () => {
    this.setState({
      isAuthenticated : false,
      authenticationChecked: false
    }, () =>{
      this.props.history.push("/dashboard")
    })

  }

但由于某种原因,它推送了历史记录,我可以在导航菜单中看到它,但它不会加载组件,我只有一个空白屏幕。 如果我在导航栏中手动输入地址,它可以正常工作

这是我的代码逻辑错误,这成功了

    logout = () => {
    this.setState({
      isAuthenticated : false,
      authenticationChecked: true
    }, () =>{
      this.props.history.push("/login")
    })

  }