Skip to content
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

[...Array(5).keys()] not working in Android #18426

Closed
James2516 opened this issue Mar 17, 2018 · 14 comments
Closed

[...Array(5).keys()] not working in Android #18426

James2516 opened this issue Mar 17, 2018 · 14 comments
Labels
Bug JavaScript Platform: Android Android applications. Ran Commands One of our bots successfully processed a command. Resolution: Fixed A PR that fixes this issue has been merged. Resolution: Locked This issue was locked by the bot.

Comments

@James2516
Copy link

James2516 commented Mar 17, 2018

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

OS: macOS Sierra 10.12.6
Node: 9.8.0
Yarn: 1.5.1
npm: 5.6.0
Watchman: 4.7.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
react: ^16.3.0-alpha.1 => 16.3.0-alpha.2
react-native: 0.54.2 => 0.54.2

Steps to Reproduce

console.log([...Array(2).keys()]) does not produce [0, 1].

  1. Run https://snack.expo.io/SJT6PCPPZ on Android (works)
  2. Run https://snack.expo.io/H1elODwPb on Android (nothing rendered on screen)
    Additional note: both works on iOS.

Expected Behavior

https://snack.expo.io/H1elODwPb should render data on screen

Actual Behavior

https://snack.expo.io/H1elODwPb renders nothing on screen

Reproducible Demo

see above

@react-native-bot
Copy link
Collaborator

Thanks for posting this! It looks like your issue may be missing some necessary information. Can you run react-native info and edit your issue to include these results under the Environment section?

Thank you for your contributions.

@react-native-bot react-native-bot added Needs More Information ❔ Ran Commands One of our bots successfully processed a command. labels Mar 17, 2018
@react-native-bot react-native-bot added Platform: Android Android applications. Ran Commands One of our bots successfully processed a command. labels Mar 18, 2018
@hramos
Copy link
Contributor

hramos commented Mar 19, 2018

Seems like a JavaScriptCore issue (this is the JavaScript engine used by React Native).

As a point of comparison, using V8 we get identical results:

[...Array(5).keys()].map(String)
(5) ["0", "1", "2", "3", "4"]
['0', '1', '2', '3', '4'].map(String)
(5) ["0", "1", "2", "3", "4"]

IIRC, we use a fork of the JSC on Android which diverged from what iOS provides.

@guhungry
Copy link
Contributor

guhungry commented Mar 23, 2018

I also found this problem on Android.
When I turn off 'Remote JS Debugging' it shows as [].
But when I turn on 'Remote JS Debugging' it shows [0, 1, 2, 3, 4].

![screenshot](https://user-images.githubusercontent.com/4032276/37819555-718a2476-2eb0-11e8-85d9-11b6b3ae2bfd.gif)
PS. iOS always work

@hramos
Copy link
Contributor

hramos commented Mar 23, 2018

You're using a different JavaScript engine when remote JS debugging is turned on - possibly Chrome's (V8).

@hramos hramos removed the Platform: macOS Building on macOS. label Mar 29, 2018
@stale
Copy link

stale bot commented Jun 27, 2018

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jun 27, 2018
@James2516
Copy link
Author

still not fixed.

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Jun 28, 2018
@sonaye
Copy link
Contributor

sonaye commented Jul 13, 2018

Workaround:

Array(5).fill().map((_, index) => index)

@ghost
Copy link

ghost commented Aug 31, 2018

Workaround by @sonaye works properly, but issue is still not fixed.

@liuqiang1357
Copy link

liuqiang1357 commented Oct 17, 2018

Still not fixed in 0.57

@stale
Copy link

stale bot commented Jan 16, 2019

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 16, 2019
@James2516
Copy link
Author

not yet fixed

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 16, 2019
@waveChand
Copy link

Not yet fixed. still happens when remote debugging turned off.

@hramos
Copy link
Contributor

hramos commented Feb 11, 2019

The JSC in Android was updated in December, it's in master. The new JSC will be part of the 0.59 release. Can you verify on master and let us know if it's still an issue?

@guhungry
Copy link
Contributor

alert([...Array(2).keys()]) works in 0.59.0
Screen Shot 2562-03-14 at 14 19 08

@hramos hramos added the Resolution: Fixed A PR that fixes this issue has been merged. label Mar 14, 2019
@hramos hramos closed this as completed Mar 14, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Mar 14, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug JavaScript Platform: Android Android applications. Ran Commands One of our bots successfully processed a command. Resolution: Fixed A PR that fixes this issue has been merged. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

8 participants