For ... loop doesn't work when remote debugger is disabled

When the debugger is disabled, I get this error:

undefined is not a function (evaluating '_iterator[typeof Symbol === 'function' Symbol.iterator:'@@iterator']()')

But when it's enabled my code works fine. This only happens on Android. The ios app works fine.

Here are my dependencies:

  • react
  • react native
  • home base
  • base-64
  • region

And here's the code that makes the difference:

for(toy of toys) {
   console.log(toy)
}

      

If I uncomment the line above, my code works without a debugger.

+3


source to share


1 answer


This is not a complete answer, but based on the MDN documentation, you can use a loop for ... of ...

on an iterative object. That is, the object must implement the interface @@iterator

.

For some reason, it seems that when debugging a running JS interpreter, it behaves differently (possibly because a different SDK is used when debugging).



EDIT: There seems to be issues with Symbol and @@ iterator in React Native: https://github.com/facebook/react-native/pull/5294#issuecomment-190061913

This issue was originally present in Android and iOS 8.x, but has been fixed for iOS 9 (this explains why your code works there). The Android version still seems to have some issues.

0


source







All Articles