【发布时间】:2021-02-12 13:01:40
【问题描述】:
我正在使用 redux-thunks,但在调用操作时遇到了问题。我的代码如下所示:
我的动作是这样的:
export const listTeams = (league: string) => {
console.log('This is logged'); <------ This is logged
return async dispatch => {
console.log('never logged!!!!'); <------- never gets here
await teamActions.listTeams(league)
.then(team => {
dispatch(setTeam(team));
})
.catch(error => handleErrors(error, dispatch));
};
};
调用它的组件如下所示:
const App = () => {
.... code
const fetchData = async() => {
await listTeams('Liverpool');
};
... more code
}
【问题讨论】:
标签: reactjs redux redux-thunk