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

Destructuring object with rest operator failed when using Number keys #18273

Closed
riwu opened this issue Mar 8, 2018 · 2 comments
Closed

Destructuring object with rest operator failed when using Number keys #18273

riwu opened this issue Mar 8, 2018 · 2 comments
Labels
JavaScript Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@riwu
Copy link

riwu commented Mar 8, 2018

const obj = { 1: 'v1', 2: 'v2' };
const key = 1;

const { [String(key)]: a, ...b } = obj;
console.log(a, b); // a is 'v1', b is { 2: 'v2' }

const { [key]: c, ...d } = obj;
console.log(c, d); // c is 'v1', d is { 1: 'v1', 2: 'v2' }

Demo: https://snack.expo.io/@riwu/destructuring-number-key

Works as intended on Chrome browser, but gave the same output as above when using Chrome debugging, which supposedly uses the same V8 engine as Chrome browser?

Environment

Environment:
OS: macOS Sierra 10.12.6
Node: 9.6.1
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.2.0 => 16.2.0
react-native: https://github.com/expo/react-native/archive/sdk-25.0.0.tar.gz => 0.52.0

@react-native-bot
Copy link
Collaborator

Thanks for posting this! It looks like your issue may refer to an older version of React Native. Can you reproduce the issue on the latest stable release?

Thank you for your contributions.

How to ContributeWhat to Expect from Maintainers

@react-native-bot react-native-bot added Old Version Ran Commands One of our bots successfully processed a command. labels Mar 8, 2018
@react-native-bot react-native-bot added the Platform: macOS Building on macOS. label Mar 20, 2018
@hramos hramos added JavaScript and removed Platform: macOS Building on macOS. labels Mar 27, 2018
danthomps added a commit to danthomps/react-native-habit-tracker that referenced this issue May 6, 2018
- Currently there is a bug with React Native where the rest operator
does not work when destructuring with an integer key.

- Casting to a string is a temporary fix.

- facebook/react-native#18273
@react-native-bot
Copy link
Collaborator

I am closing this issue because it does not appear to have been verified on the latest release, and there has been no followup in a while.

If you found this thread after encountering the same issue in the latest release, please feel free to create a new issue with up-to-date information by clicking here.

@facebook facebook locked as resolved and limited conversation to collaborators May 16, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label May 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
JavaScript Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

3 participants