是否已经可以在 react-native 中使用顶级 await? [英] Is it already possible to use top-level await in react-native?

查看:47
本文介绍了是否已经可以在 react-native 中使用顶级 await?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否已经可以在 react-native 中使用顶级 await?我看到它已被添加到 TypeScript 3.8(我没有使用 TS,我只是想看看它是否有帮助,但没有).然而,在 react-native 文件转换是由 babel 处理的,我认为当前的 Metro 预设无法处理顶级等待.有什么办法可以让它工作吗?

Is it already possible to use top-level await in react-native? I saw it's been added to TypeScript 3.8 (I was not using TS, I just tried to see if it would help but no). However in react-native file transform is handled by babel and I don't think the current metro preset handles top-level awaits. Is there any way to make it work?

推荐答案

ECMAScript 功能顶级 await 有两个条件:

ECMAScript feature top-level await stands on two conditions:

  1. ES2017+
  2. ECMAScript 原生模块(它们被编译为函数)

但是 React-Native 使用节点模块,所以答案是.

But React-Native uses node modules, so the answer is no.

查看Ecma 国际标准了解更多

这篇关于是否已经可以在 react-native 中使用顶级 await?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆