同一函数中的 Redux 调用函数和调度类型
Redux call function and dispatch type in same function
我有一个用于会话超时和注销的 redux 操作。 Sessiontimeout调用时,内部调用注销函数。
它也没有用 SESSIONTIMEOUT
未调度操作类型。
我想如何在 Sessiontimeout 中调用注销并分派 SESSIONTIMEOUT
和 LOGOUT
export function sessionTimeOut(){
return (dispatch) => {
dispatch({
type: ACTIONTYPES.SESSIONTIMEOUT
})
}
logout()
}
export function logout(){
history.push('/')
return {
type: ACTIONTYPES.LOGOUT
}
}
在 SESSIONTIMEOUT
操作后立即调度 logout()
。
export function sessionTimeOut(){
return (dispatch) => {
dispatch({
type: ACTIONTYPES.SESSIONTIMEOUT
});
dispatch(logout());
}
}
我有一个用于会话超时和注销的 redux 操作。 Sessiontimeout调用时,内部调用注销函数。
它也没有用 SESSIONTIMEOUT
未调度操作类型。
我想如何在 Sessiontimeout 中调用注销并分派 SESSIONTIMEOUT
和 LOGOUT
export function sessionTimeOut(){
return (dispatch) => {
dispatch({
type: ACTIONTYPES.SESSIONTIMEOUT
})
}
logout()
}
export function logout(){
history.push('/')
return {
type: ACTIONTYPES.LOGOUT
}
}
在 SESSIONTIMEOUT
操作后立即调度 logout()
。
export function sessionTimeOut(){
return (dispatch) => {
dispatch({
type: ACTIONTYPES.SESSIONTIMEOUT
});
dispatch(logout());
}
}