[transform-react-jsx] Add useSpread option to transform JSX (#10572)
* [transform-react-jsx] Add useSpread option to transform JSX * Add validation for default option * Add error when using useSpread and useBuiltIns at the same time * Move useSpread to convertAttribute helper function * Add useSpread option to presect-react * Remove casting useSpread to boolean in preset-react option. Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
This commit is contained in:
committed by
Nicolò Ribaudo
parent
8ffca0475a
commit
3d2f365074
@@ -0,0 +1 @@
|
||||
var div = <Component {...props} foo="bar" />
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"plugins": [["transform-react-jsx", { "useSpread": 0 }]],
|
||||
"throws": "transform-react-jsx currently only accepts a boolean option for useSpread (defaults to false)"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
var div = <Component {...props} foo="bar" />
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"plugins": [
|
||||
["transform-react-jsx", { "useSpread": true, "useBuiltIns": true }]
|
||||
],
|
||||
"throws": "transform-react-jsx currently only accepts useBuiltIns or useSpread but not both"
|
||||
}
|
||||
1
packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment/input.js
vendored
Normal file
1
packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var div = <Component {...props} foo="bar" />
|
||||
3
packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment/output.js
vendored
Normal file
3
packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment/output.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
var div = React.createElement(Component, { ...props,
|
||||
foo: "bar"
|
||||
});
|
||||
3
packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/options.json
vendored
Normal file
3
packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": [["transform-react-jsx", { "useSpread": true }]]
|
||||
}
|
||||
Reference in New Issue
Block a user