@babel/plugin-transform-react-jsx-compat

Example

In

  1. var profile = (
  2. <div>
  3. <img src="avatar.png" class="profile" />
  4. <h3>{[user.firstName, user.lastName].join(" ")}</h3>
  5. </div>
  6. );

Out

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

Installation

  1. npm install --save-dev @babel/plugin-transform-react-jsx-compat

Usage

  1. {
  2. "plugins": ["@babel/plugin-transform-react-jsx-compat"]
  3. }

Via CLI

  1. babel --plugins @babel/plugin-transform-react-jsx-compat script.js

Via Node API

  1. require("@babel/core").transformSync("code", {
  2. plugins: ["@babel/plugin-transform-react-jsx-compat"],
  3. });