You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
into your .babelrc and get the latest and greatest JS features. That's why we created the preset...it makes it easy for people to get started with a custom babelrc. Unfortunately, the stage-3 babel preset contains "async-to-generator", which transforms async function blah() into function* blah(). This is not necessary for react-native (and as you all have discovered, actually breaks), as it already includes transform-regenerator, which allows for consistent use of generators and async functions on the versions of JSC that react-native uses.
我的理解:
错误描述
错误信息
错误截图
讨论 "babelHelpers.asyncToGenerator is not a function" on React-Native 0.16.0 and 0.17.0
错误背景
我的的
.babelrc
错误原因
如同讨论中skevy所说
stage-3
包含async-to-generator
,stage-0
包含stage-3
.plugins
中包含async-to-generator
. 重复一次。react-native
中也包含async-to-generator
. 重复两次。解决方法
方法一
{ "presets": [ "react-native" ] }方法二(添加一些可能会用到的plugin)
方法三(与方法二原理相同,只是更加简单)
延伸
根据方法三,加深了对与Babel的理解。
preset, 中文“预设”,应该是说这个preset预设了很多需要用到的Plugin,不需要你自己一个一个的添加了。例如,以[babel-preset-react-native](https://github.com/facebook/react-native/tree/master/babel-preset`为例,写法"presets": [ "react-native" ],`,其中包括很多babel Plugin,如下:
plugin, 中文“插件”,babel最基本的转换单元。
The text was updated successfully, but these errors were encountered: