How to use await key word on react native?

后端 未结 4 1405
[愿得一人]
[愿得一人] 2020-12-09 07:28

I tried to use await/async on react native,but I got unexpected token error.

I added the code blow in my javascript source file:

var value = await As         


        
4条回答
  •  臣服心动
    2020-12-09 08:05

    After reading this comment on the react-native GitHub issues, the following worked for me:

    Add the following npm module:

    npm install babel-preset-react-native-stage-0 --save

    Add the following configuration to your .babelrc file:

    { presets: ['react-native-stage-0'] }

    Clear your cache:

    $ watchman watch-del-all
    $ ./node_modules/react-native/packager/packager.sh --reset-cache
    

提交回复
热议问题