Add babel polyfill to React Native Project

蓝咒 提交于 2019-12-07 06:49:32

问题


I´m having a issue on android. Got this error:

undefined is not a function(evaluating '_iterator2typeof Symbol==='function'?Symbol.iterator:'@@iterator'´)

I think it is related to the use of for of, es6.

Can i add babel-polyfill to React Native Project ?


回答1:


In order to add babel-polyfill to your react-native project after installing

npm install --save babel-polyfill

just import it like this in your entry endpoint:

import 'babel-polyfill';

Now you can use new built-ins like Promise or WeakMap, static methods like Array.from and instance methods like Array.prototype.includes, etc.




回答2:


You can use

npm install es6-symbol --save

Then add in your index.android.js & index.ios.js

import 'es6-symbol/implement'


来源:https://stackoverflow.com/questions/37731475/add-babel-polyfill-to-react-native-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!