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

Function with destructuring assignment breaks react dev build #957

Closed
untitledlt opened this issue Jun 1, 2020 · 4 comments
Closed

Function with destructuring assignment breaks react dev build #957

untitledlt opened this issue Jun 1, 2020 · 4 comments

Comments

@untitledlt
Copy link

Reposting this from Babel issues as Babel team says it's acornjs related.

Bug Report

Tested on clean create-react-app install.
This function in any component file breaks React app:

const myFn = ({ set = '' }) => {};

Current behavior

./src/App.js 7:6
Module parse failed: Unexpected token (7:6)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
 * ./node_modules/eslint-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
| 
| const myFn = ({
>   set = ''
| }) => {};
|

if I change set to anything else, everything works fine.

Input Code

const myFn = ({ set = '' }) => {};

Expected behavior
Should transpile without errors.

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
Clean, not ejected create-react-app.

Environment

- Babel version(s): [7.9.0]
- Node/npm version: [12.14.0]
- OS: [macOS 10.15.4]
- Monorepo: [no]
- How you are using Babel: [`loader`]

Possible Solution
Do not use set as object property

@marijnh marijnh closed this as completed in eec9b37 Jun 1, 2020
@untitledlt
Copy link
Author

@marijnh why is it closed?

@RReverser
Copy link
Member

@untitledlt As you can see above, it was closed by a commit that fixes this issue.

@untitledlt
Copy link
Author

oh sorry, missed that. Thanks!

@RReverser
Copy link
Member

Thanks for the detailed report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants