Codesandbox-client: Unable to use Object rest spread destructuring

Created on 26 Jun 2018  ·  9Comments  ·  Source: codesandbox/codesandbox-client

🐛 bug report

Description of the problem

Unable to use Object rest spread destructuring

How has this issue affected you? What are you trying to accomplish?

I'm trying to separate the children from the rest of my props so I can clone them. My initial thought was to use const { children, ...remainingProps} = props but my program isn't able to compile.

Link to sandbox: [link](https://codesandbox.io/s/wwnpn034z7

) (optional)
https://codesandbox.io/s/wwnpn034z7

Your Environment

| Software | Name/Version|
| ---------------- | ---------- |
| Сodesandbox | PROD-1529759986-6047bf5
| Browser | Chrome 67
| Operating System | Mac

❕ Help Wanted 🔰 Beginner Friendly

Most helpful comment

I had the same issue. Creating a .babelrc file sloved also the issue.

For those who wants to know how to do it easily:
Go to: Configuation Files > .babelrc > Create File
Then paste:

{
  "presets": [
    "env"
  ],
  "plugins": [
    "transform-object-rest-spread"
  ]
}

NB: no need to add babel-plugin-transform-object-rest-spread package.

All 9 comments

Wow I love your sandbox! I think it's fixed by adding the object-spread
plugin of babel to the configuration of babel, like this:
https://codesandbox.io/s/133w8o3vpq. I will check if this is also needed in
Parcel!

On Tue, Jun 26, 2018 at 4:13 PM Ben Wilcox notifications@github.com wrote:

🐛 bug report Description of the problem

Unable to use Object rest spread destructuring
How has this issue affected you? What are you trying to accomplish?

I'm trying to separate the children from the rest of my props so I can
clone them. My initial thought was to use const { children,
...remainingProps} = props but my program isn't able to compile.
Link to sandbox: [link](https://codesandbox.io/s/wwnpn034z7

) (optional)
https://codesandbox.io/s/wwnpn034z7
Your Environment
Software Name/Version
Сodesandbox PROD-1529759986-6047bf5
Browser Chrome 67
Operating System Mac


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/CompuIves/codesandbox-client/issues/930, or mute the
thread
https://github.com/notifications/unsubscribe-auth/AAj1COc7JWHJ6VLQmXdEFfJRIjaA3w3Aks5uAk-wgaJpZM4U4Jpy
.

That did the trick for me! I've been following along with the Wes Bos Redux tutorials and Codesandbox has been a great environment for it. Thanks!

I had the same issue. Creating a .babelrc file sloved also the issue.

For those who wants to know how to do it easily:
Go to: Configuation Files > .babelrc > Create File
Then paste:

{
  "presets": [
    "env"
  ],
  "plugins": [
    "transform-object-rest-spread"
  ]
}

NB: no need to add babel-plugin-transform-object-rest-spread package.

Thanks for the clear solution @renaudtertrais! Very appreciated!

I think this is a good starter for people that are looking to contribute. The things that need to be done:

  1. Find out if object destructuring works in Parcel without .babelrc.
  2. If that's the case, push the tranform-object-rest-spread plugin to this array (https://github.com/CompuIves/codesandbox-client/blob/master/packages/common/templates/configuration/babelrc/index.js#L100).

I'm reopening this issue until we have closure on this 😄.

@CompuIves According to this thread, rest-spread destructuring should get added once they upgrade to Babel 7: https://github.com/parcel-bundler/parcel/issues/1221

The issue they're reference hasn't been updated in about 2 months, so I'm not sure how far along they are. What do you think we should do in the meantime? Just wait and see, or add the transform-object-rest-spread plugin?

Another update: Based on the response in this thread, it sounds like support for Babel 7 probably isn't coming until Parcel 2: https://github.com/parcel-bundler/parcel/issues/868

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Issue closed due to lack of activity

for me i had to pass extra properties
[
"transform-object-rest-spread",
{
"useBuiltIns": true
}
]

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eckmLJE picture eckmLJE  ·  3Comments

CompuIves picture CompuIves  ·  3Comments

miukimiu picture miukimiu  ·  3Comments

wojciechczerniak picture wojciechczerniak  ·  3Comments

Haroenv picture Haroenv  ·  3Comments