babel-plugin-transform-react-remove-prop
v0.1.3
Published
Remove selected attributes in each react element by selected conditions
Downloads
251
Readme
babel-plugin-transform-react-remove-prop
Remove selected attributes in each react element by selected conditions
Install
Using npm:
npm install --save-dev babel-plugin-transform-react-remove-prop
or using yarn:
yarn add babel-plugin-transform-react-remove-prop --dev
Usage
Add the following line to your .babelrc file.
Without options
{
"plugins": ["babel-plugin-transform-react-remove-prop"]
}
With options (and their defaults):
{
"plugins": [
[
"babel-plugin-transform-react-remove-prop",
{
"attrs": ["data-test-id"]
}
]
]
}
Options
attrs
array, defaults to ["data-test-id"]
Array of attribute names that should be removed from react elements.
Supported syntax
JS
// React.createElement
React.createElement('div', { 'data-test-id': 'id' })
// Preact / Object.assign syntax
h('div', Object.assign({}, props, { 'data-test-id': 'id' }))
// Object spread
React.createElement('div', { ...props, 'data-test-id': 'id' })
JSX
// Simple attribute
<div data-test-id='id' />
// Object spread
<div {...{ 'data-test-id': 'id' }} />