babel-plugin-jsx-attributes-array-to-object
A tool for transforming jsx attributes array to object
Last updated 5 years ago by shinken008 .
MIT · Original npm · Tarball · package.json
$ cnpm install babel-plugin-jsx-attributes-array-to-object 
SYNC missed versions from official npm registry.

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'],
    }]
  ]
}

Current Tags

  • 0.3.0                                ...           latest (5 years ago)

3 Versions

  • 0.3.0                                ...           5 years ago
  • 0.2.0                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 3
Dependencies (0)
None
Dev Dependencies (8)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |