react-native - 获取 Actions 必须是 react native redux 中的普通对象
问题描述
嗨,我收到了错误Error: Actions must be plain objects. Use custom middleware for async actions.
,但我正在使用 redux-thunk,并且我已经对正在使用的异步调用进行了一些操作。有人知道我为什么会收到此错误吗?
export function reportUser(userId, idBlocked, raisons) {
return function (dispatch) {
return axios({
url: url,
method: 'post',
data: {
id: userId,
membres_id: idBlocked,
raisons: raisons,
},
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
})
.then(function (response) {
dispatch({ type: 'SET_REPORT_USER', payload: response.data });
console.log(response.data);
setTimeout(() => {
Alert.alert('Le membre a bien été débloqué.');
}, 500); // Wait nav complete
})
.catch(function (error) {
console.log(error);
});
};
}
提前致谢 !
解决方案
推荐阅读
- javascript - curl 和浏览器提供不同的 http 响应
- c# - ASP.NET Core 中的 AzureAD B2C ROPC 身份验证
- .net-core - 删除迁移和更新数据库实体框架核心时出错 从流中读取时出错
- reactjs - 如何配置 React 客户端、.NET Core 3.1 后端、单租户 SSO
- drake - np.linalg.solve() 是否不适用于 AutoDiff?
- r - 围绕 data.table 中的特定值对时间序列进行子集化
- java - java中的正则表达式(java字符串)
- html - 为什么我的页脚内的 2 个 div 进入不同的角落?
- c++ - std::function 来自“new”并输入
- java - 在 .war 中编译一个 java 类