gpt4 book ai didi

react-router - 如何处理 Redux 中的注销路由?

转载 作者:行者123 更新时间:2023-12-04 01:36:18 26 4
gpt4 key购买 nike

我想定义一个可用于注销用户的 URL(发送一个可以注销用户的操作)。我还没有找到展示如何实现路由调度事件的示例。

最佳答案

这是此类 /logout 的最新实现页:

import { Component, PropTypes } from 'react'
import { connect } from 'react-redux'
import { withRouter } from 'react-router'
import * as authActionCreators from '../actions/auth'

class LogoutPage extends Component {

componentWillMount() {
this.props.dispatch(authActionCreators.logout())
this.props.router.replace('/')
}

render() {
return null
}
}
LogoutPage.propTypes = {
dispatch: PropTypes.func.isRequired,
router: PropTypes.object.isRequired
}

export default withRouter(connect()(LogoutPage))

关于react-router - 如何处理 Redux 中的注销路由?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34720034/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com