babel-plugin-jsx-attributes-array-to-object

0.3.0 • Public • Published

babel-plugin-jsx-attributes-array-to-object

A tool for transforming jsx attributes array to object.

example

var a = { color: 'red' };
  
<div style={[a, { color: 'gray' }]}></div>

and the configure like this:

// babel.config.js
[
  syntaxJSX,
  [require('babel-plugin-jsx-attributes-array-to-object
'), { attributes: ['style'] }],
]

the code will be transformed:

var a = {
  color: 'red'
};
var b = {};
<div style={Object.assign({}, a, {
  color: 'gray'
})}></div>;

Usage

Step 1: Install

yarn add --dev babel-plugin-jsx-attributes-array-to-object

or

npm install --save-dev babel-plugin-jsx-attributes-array-to-object

Step 1: Configure .babelrc

{
  plugins: [
    [require('babel-plugin-jsx-attributes-array-to-object'), {
      attributes: ['style'],
    }]
  ]
}

Package Sidebar

Install

npm i babel-plugin-jsx-attributes-array-to-object

Weekly Downloads

1,168

Version

0.3.0

License

MIT

Unpacked Size

7.26 kB

Total Files

9

Last publish

Collaborators

  • shinken008