Javascript history.location.replace不是使用react router v4的函数

Javascript history.location.replace不是使用react router v4的函数,javascript,reactjs,redux,Javascript,Reactjs,Redux,在redux的组件WillReceiveCeprops中,我可以使用react路由器进行重定向吗?是我干的 componentWillReceiveProps(nextProps) { if(nextProps.user.isAuthenticated !== this.props.user.isAuthenticated && nextProps.user.isAuthenticated) { console.log(nextProps.history)

在redux的组件WillReceiveCeprops中,我可以使用react路由器进行重定向吗?是我干的

componentWillReceiveProps(nextProps) {
    if(nextProps.user.isAuthenticated !== this.props.user.isAuthenticated && nextProps.user.isAuthenticated) {
        console.log(nextProps.history)
        nextProps.history.location.replace('/dashboard')
    }
  }
但是错误出现在
nextrops.history.location.replace('/dashboard')
我也尝试了
this.history.location.replace('/dashboard')


但是当我
console.log(nextrops.history)
时,方法就在那里。有什么问题吗?

您需要使用
这个.props.history.push(“/dashboard”)
历史中的
位置
对象没有此方法。看看这本书。可在
历史记录中直接访问:

nextProps.history.replace('/dashboard')

做一点改变:
nextrops
而不是
this
@BhojendraNepal这一点都不重要。