@alita/babel-transform-jsx-class

0.0.2 • Public • Published

babel-plugin-transform-jsx-class

Support classnames with directive.

Example

In

import { createElement } from 'react';

export default function Foo(props) {
  const { message } = props;
  return (
    <div x-class={['foo', {
      bar: true,
      active: false,
    }]}>hello world</div>
  );
}

Out

import { createElement } from 'react';

export default function Foo(props) {
  const { message } = props;
  return (
    <div className={classnames(['foo', {
	    bar: true,
	    active: false,
	  }])}>hello world</div>
  );
}

Installation

$ npm install babel-plugin-transform-jsx-class

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["transform-jsx-class"]
}

Via CLI

$ babel --plugins transform-jsx-class script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-jsx-class"]
});

Readme

Keywords

Package Sidebar

Install

npm i @alita/babel-transform-jsx-class

Weekly Downloads

7,340

Version

0.0.2

License

MIT

Unpacked Size

9.36 kB

Total Files

13

Last publish

Collaborators

  • pengyh
  • ashoka_j
  • hang1017
  • hammersjs
  • cjy0208
  • xiaohuoni