【发布时间】:2017-04-30 01:29:56
【问题描述】:
我有以下操作
export function getAllBooks() {
return function(dispatch) {
return axios.get('http://localhost:8080/books')
.then(response => dispatch(retrieveBooks(response.data)));
};
}
问题是当我调用此操作时,我进入了控制台
Uncaught (in promise) TypeError: dispatch is not a function 在 eval (eval at ...
那是.then(response => dispatch(retrieveBooks(response.data)));中的dispatch正在播放
我尝试删除除 redux-thunk 之外的所有其他中间件,但无济于事
动作的唯一使用地点是在
const mapDispatchToProps = (dispatch) => {
return { fetchBooks : () => dispatch(getAllBooks) };
}
【问题讨论】:
-
你检查过
dispatch实际上是什么吗? -
然后记录
dispatch对象
标签: redux redux-thunk