【发布时间】:2021-03-03 09:42:07
【问题描述】:
将图像和数据上传到 firebase 并且它的回调很好。 但是在 promise 函数中,我得到了 Can't find variable : setPosts 的错误,它是由 Actions on Redux 定义的 这里
[Unhandled promise rejection: ReferenceError: Can't find variable: setPosts]
- node_modules\native-base\dist\src\basic\Tabs\DefaultTabBar.js:1:328 in <global>
- node_modules\react-native\node_modules\promise\setimmediate\core.js:37:13 in tryCallOne
- node_modules\react-native\node_modules\promise\setimmediate\core.js:123:24 in setImmediate$argument_0
- node_modules\react-native\Libraries\Core\Timers\JSTimers.js:130:14 in _callTimer
- node_modules\react-native\Libraries\Core\Timers\JSTimers.js:181:14 in _callImmediatesPass
- node_modules\react-native\Libraries\Core\Timers\JSTimers.js:441:30 in callImmediates
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:387:6 in __callImmediates
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:135:6 in __guard$argument_0
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guard
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:134:4 in flushedQueue
* [native code]:null in flushedQueue
* [native code]:null in callFunctionReturnFlushedQueue
还有代码
// For Media
const onPresslaunchCameraMedia = async () => {
let result = await ImagePicker.launchCameraAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images,
quality: 1,
});
if (!result.cancelled) {
console.log("============ Media Uploaded By Photo =============")
console.log(result.uri)
await setMediaData({...mediaData, country : userData.country})
await uploadMedia(mediaData, result.uri)
dispatch(addPost(mediaData));
navigation.dispatch(StackActions.replace('Home'));
}
};
使用 expo-cli 启动 react-native 应用
【问题讨论】:
标签: reactjs react-native react-hooks expo