Skip to content

Commit

Permalink
Always include destructuring transform (#3788)
Browse files Browse the repository at this point in the history
* Always include destructuring transform

* Fix lint
  • Loading branch information
gaearon committed Jan 14, 2018
1 parent 1e9eaf3 commit 22f9fe0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/babel-preset-react-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
'use strict';

const plugins = [
// Necessary to include regardless of the environment because
// in practice some other transforms (such as object-rest-spread)
// don't work without it: https://github.com/babel/babel/issues/7215
require.resolve('babel-plugin-transform-es2015-destructuring'),
// class { handleClick = () => { } }
require.resolve('babel-plugin-transform-class-properties'),
// The following two plugins use Object.assign directly, instead of Babel's
Expand Down
1 change: 1 addition & 0 deletions packages/babel-preset-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"babel-plugin-dynamic-import-node": "1.1.0",
"babel-plugin-syntax-dynamic-import": "6.18.0",
"babel-plugin-transform-class-properties": "6.24.1",
"babel-plugin-transform-es2015-destructuring": "6.23.0",
"babel-plugin-transform-object-rest-spread": "6.26.0",
"babel-plugin-transform-react-constant-elements": "6.23.0",
"babel-plugin-transform-react-jsx": "6.24.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export default class extends Component {
return (
<div id="feature-object-destructuring">
{this.state.users.map(user => {
const { id, name } = user;
const { id, ...rest } = user;
// eslint-disable-next-line no-unused-vars
const [{ name, ...innerRest }] = [{ ...rest }];
return <div key={id}>{name}</div>;
})}
</div>
Expand Down

0 comments on commit 22f9fe0

Please sign in to comment.