问题描述
我计划在我的 React Native - Expo 项目中将一些 Promise.all 更新为 Promise.allSettled,但该功能不存在.我检查了所有版本,一切都合适,但我仍然无法使用该功能.
I planned updating some Promise.all to Promise.allSettled in my React Native - Expo Project but the function does not Exist. i checked all Versions and everything fits but i still cant use the function.
节点-v:14.15.4
node -v: 14.15.4
expo SDK -v 版本:^40.0.1
expo SDK -v version: ^40.0.1
expo 在其 SDK 版本中使用 react native -v 0.63.这应该不是问题.这是错误信息:
expo uses react native -v 0.63 in their SDK version. This should not be the problem. This is the error message:
Promise.allSettled 不是函数
Promise.allSettled is not a function
有人知道这个问题的解决方案吗?感谢您的帮助!
Does anybody knows a solution to this? Thank you for your help!
推荐答案
对于遇到此问题的任何人,显然这已在 v64 中修复:
For anyone coming across this issue, apparently this was fixed in v64:
https://github.com/facebook/react-native/issues/30236#issuecomment-939286987
对于旧版本,您可以使用简单的 polyfill:
For older versions, you can use a simple polyfill:
Promise.allSettled = Promise.allSettled || ((promises) => Promise.all(
promises.map(p => p
.then(value => ({
status: "fulfilled",
value
}))
.catch(reason => ({
status: "rejected",
reason
}))
)
));
这篇关于Promise allSettled 不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)