你必须这么做
refreshToken()
。如果您确实可以访问
dispatch()
进入
jwt
函数你应该这样称呼它
dispatch(refreshToken())
考虑到我不确定你是如何触发
jwt公司
// ================
// Container file
// ================
import {connect} from "react-redux";
import { bindActionCreators } from "redux";
// ... other
function mapActionsToProps(dispatch) {
return bindActionCreators({
jwt: path_to_actions_file.jwt
}, dispatch)}
const mapStateToProps = (state) => ({
// ... your state properties
});
export default connect(mapStateToProps, mapActionsToProps)(YourComponent); // <== YourComponent has to be a React Component
// ==============
// Actions file
// ==============
export const setConvertTypeActive = store => dispatch => {
console.log('This is logging.');
dispatch(refreshToken("md5Token"));
}
export const refreshToken = refreshToken => dispatch => {
console.log('Should log now.');
}
关于最后一个问题,是的,你可以创建类似于
refreshToken
在减速器上设置某些状态的操作。检查以下代码:
// ==============
// Actions file
// ==============
export const refreshToken= {
pending: () => ({
// "REFRESH_TOKEN_PENDING"
}),
success: (data) => ({
// "REFRESH_TOKEN_SUCCESS"
})
};