babel/packages/babel-plugin-transform-react-jsx-compat
Daniel Tschinder b3372a572d Remove whitespace generation (#5833)
* Remove whitespace generation and rely on default printing

Changes to printing:
* Add newline after last empty SwitchCase
* Add newlines around block comments if they are non-flow comments or contain newlines

* Fix a few more fixtures
2017-06-27 21:57:02 -05:00
..
2017-06-27 12:15:00 -05:00
2017-06-27 21:57:02 -05:00
2017-03-25 21:46:16 -04:00
2017-05-31 17:11:39 -04:00

babel-plugin-transform-react-jsx-compat

Turn JSX into React Pre-0.12 function calls

Example

In

var profile = <div>
  <img src="avatar.png" class="profile" />
  <h3>{[user.firstName, user.lastName].join(' ')}</h3>
</div>;

Out

var profile = React.DOM.div(null,
  React.DOM.img({ src: "avatar.png", "class": "profile" }),
  React.DOM.h3(null, [user.firstName, user.lastName].join(" "))
);

Installation

npm install --save-dev babel-plugin-transform-react-jsx-compat

Usage

.babelrc

{
  "plugins": ["transform-react-jsx-compat"]
}

Via CLI

babel --plugins transform-react-jsx-compat script.js

Via Node API

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