Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
react: Use babel-preset-react's new useSpread option (#1488)
Browse files Browse the repository at this point in the history
A new `useSpread` option was added in Babel 7.7.0 (babel/babel#10572):
https://babeljs.io/docs/en/babel-preset-react#usespread

Enabling this means that the JSX-> JS conversion will use an inline
object with spread elements (for code that spreads props), rather than
Babel's extend helper or `Object.assign`.

`@babel/env` will still transpile these down if required for the target
browsers (the only reason `useSpread` is not already enabled by default
is that for the upstream project this is a breaking change, since they
cannot assume that users of `babel-preset-react` are always using it
alongside `@babel/env`, even though most likely are).
  • Loading branch information
edmorley committed Nov 10, 2019
1 parent af84046 commit 4bd2031
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/react/index.js
Expand Up @@ -43,9 +43,10 @@ module.exports = (opts = {}) => neutrino => {
{
// Enable development helpers both in development and testing.
development: process.env.NODE_ENV !== 'production',
// Use the native built-in instead of polyfilling.
// Don't confuse this with `@babel/preset-env`'s `useBuiltIns` option, they are different.
useBuiltIns: true,
// When spreading props, use inline object with spread elements directly instead of
// Babel's extend helper or Object.assign. @babel/env will still transpile these down
// if required for the target browsers.
useSpread: true,
},
],
],
Expand Down

0 comments on commit 4bd2031

Please sign in to comment.