Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add babel polyfill to React Native Project

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 ?

like image 210
Andre Goncalves Avatar asked Jun 09 '16 16:06

Andre Goncalves


2 Answers

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.

like image 101
locropulenton Avatar answered Sep 18 '22 22:09

locropulenton


You can use

npm install es6-symbol --save

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

import 'es6-symbol/implement'
like image 44
Ouadie Avatar answered Sep 18 '22 22:09

Ouadie