Babel in React (babel plugin: transform-react-jsx)
@babel/plugin-transform-react-jsx
test.jsx
const profile = (
<div>
<img src="avatar.png" className="profile" />
<h3>{[user.firstName, user.lastName].join(' ')}</h3>
</div>
);
try to compile by babel
babel test.jsx
with @babel/plugin-transform-react-jsx plugin in .babelrc
Install @babel/plugin-transform-react-jsx
npm install @babel/core @babel/plugin-transform-react-jsx
Compile again
babel test.jsx --out-file test.js
const profile = React.createElement("div", null, React.createElement("img", {
src: "avatar.png",
className: "profile"
}), React.createElement("h3", null, [user.firstName, user.lastName].join(' ')));
with source map
babel test.jsx --out-file test.js --source-maps