nicolaslopezj / meteor-apollo-accounts

Meteor accounts in GraphQL
MIT License
146 stars 37 forks source link

"for in" and "for of" loops break React Native Android code #73

Open joncursi opened 7 years ago

joncursi commented 7 years ago

This repository contains several instances of for in and for of which breaks code execution on React Native Android apps.

Example: https://github.com/orionsoft/meteor-apollo-accounts/blob/3ce4f66b6cf294a96bb9d4c20d4ee43ecbb0a1be/client/src/store.js#L40

Attempting to login with password on android causes this error:

09-11 18:09:31.440  3541  3584 I ReactNativeJS: { [TypeError: undefined is not a function (evaluating 'onChangeCallbacks[typeof Symbol === 'function' ? Symbol.iterator : '@@iterator']()')]

See a similar issue logged in the css-to-react-native repo: https://github.com/styled-components/css-to-react-native/issues/31 - the problem was solved by eliminating these special loops in favor of more standard ES5 code.

joncursi commented 7 years ago

More explanation here: https://github.com/facebook/react-native/issues/4676#issuecomment-163399041

acomito commented 6 years ago

Is this what is breaking the logout on android? @joncursi

joncursi commented 6 years ago

@acomito Yeah, this library doesn't really work on React Native android devices due to Android not natively supporting Symbol. You can polyfill it with core-js though:

// index.android.js
import 'core-js/es6/symbol';
import 'core-js/fn/symbol/iterator';

But beware, doing so seems to cause other issues.

ujwal-setlur commented 6 years ago

@joncursi, I used the proposed solution at:

https://github.com/facebook/react-native/issues/4676#issuecomment-352815780

ujwal-setlur commented 6 years ago

This will fail on react-native 0.56.0. It will trigger

https://github.com/facebook/react-native/issues/18542