Is it possible to use async / await in React JS?

前端 未结 3 1505
盖世英雄少女心
盖世英雄少女心 2020-12-13 17:34

I started programming in React Native, and I got used to use the syntax:

async myFunction(){
    ...
    return await otherFunction();
}

Bu

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-13 18:32

    Alternatively you can use Typescript.

    Since version 2.1 it is possible to use async/await and directly transpile to ES5 (in other words have it run on ~all browsers)

提交回复
热议问题