Babel
  • Docs
  • Setup
  • Try it out
  • Videos
  • Blog
  • Donate
  • Team
  • GitHub
Edit

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

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

With a configuration file (Recommended)

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

Via CLI

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

Via Node API

require("@babel/core").transformSync("code", {
  plugins: ["@babel/plugin-transform-react-jsx-compat"],
});
  • Example
  • Installation
  • Usage
    • With a configuration file (Recommended)
    • Via CLI
    • Via Node API
Babel
Docs
Learn ES2015
Community
VideosUser ShowcaseStack OverflowSlack ChannelTwitter
More
BlogGitHub OrgGitHub RepoWebsite RepoOld 6.x SiteOld 5.x Site