【发布时间】:2018-05-12 22:07:19
【问题描述】:
我在 react-native 应用程序中有以下操作。我收到错误消息“dispatch 不是函数。我是 redux 新手,并且在处理异步操作时遇到了困难。有没有办法在不使用 async/await 的情况下将 Asyncstorage 设置为状态?
export const balanceCall =async (dispatch) => {
let token = await getAsyncStoreT();
let mobile= await getAsyncStoreM();
balanceURL = `https://localhost/v1/user/find?token=${token}&mobile=${mobile}`;
console.log(balanceURL);
axios({
method: 'get',
url: checkURL,
}).then(function (response) {
let balance =response.data.map(user=>user.balance);
dispatch(balanceReceived(balance));
})
.catch(function (error) {
console.log(error);
console.log("NOT AGAIN");
});
};
【问题讨论】:
标签: react-native redux redux-thunk