-
Notifications
You must be signed in to change notification settings - Fork 24.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ES6 for of
loops stopped working after upgrading to 0.16 (clean project)
#4587
Comments
Hey DanielHoffmann, thanks for reporting this issue! React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.
|
I tested out babel online REPL and it translates this simple let keys = Object.keys({});
for (let key of keys) {
console.log(keys);
} into: "use strict";
var keys = Object.keys({});
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var key = _step.value;
console.log(keys);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator["return"]) {
_iterator["return"]();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
} Which indeed uses the |
The Babel online REPL isn't a faithful representation of what's happening because the REPL uses Babel 5 while RN 0.16 uses Babel 6, not to mention potentially configuration differences (RN doesn't use babel-runtime). Maybe you could try loose mode as a shot in the dark to see if for-of compiles to a form without Symbol. Or we could eventually try to polyfill Symbol for old phones (iOS 7 and maybe 8). Upgrading JSC on Android is almost certainly doable but requires coordination from Facebook's side... @astreet @mkonicek what's your plan for keeping Android JSC up-to-date? |
I got this answer from the Babel guys: "The expectation is that you will load babel-polyfill to load a Symbol substitute or that you'd enable loose mode forOf. This behavior hasn't changed between Babel 5 and Babel 6 as far as I'm aware." It seems that react native is indeed missing the Symbol polyfill. @ide Hm, I just changed all my |
You can stick options in here: https://github.com/facebook/react-native/blob/master/packager/react-packager/.babelrc. I'm not familiar with the specifics of loose mode though so it might just be an exercise in futility. |
This is almost certainly a lack of a Symbol polyfill in JavaScriptCore. I've personally used the babel-polyfill (http://babeljs.io/docs/usage/polyfill/) to fix it...there are other Symbol polyfills that may be smaller (since babel-polyfill polyfills lots of things). Use at your discretion and let us know if it fixes it! Closing for now as it's related to a specific use case. |
I just upgraded my project from 0.15.0 to 0.16 (I created a new project from scratch and moved over my files) and now my
for of
loops are giving me this error:I tested on Android only, I do not own an iOS device. The line in question is:
Also by the way Symbol never worked on the previous version either, I actually wanted to use them, babel doesn't support them yet?
The text was updated successfully, but these errors were encountered: