Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-transform-react-jsx

Package Overview
Dependencies
Maintainers
3
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-react-jsx

Turn JSX into React function calls

  • 6.2.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
379K
decreased by-3.68%
Maintainers
3
Weekly downloads
 
Created

What is babel-plugin-transform-react-jsx?

The babel-plugin-transform-react-jsx package is a Babel plugin that transforms JSX syntax into JavaScript. This allows developers to write HTML-like syntax in their JavaScript code, which is then converted to React.createElement calls.

What are babel-plugin-transform-react-jsx's main functionalities?

Transform JSX to React.createElement

This feature allows you to write JSX syntax, which is more readable and expressive, and have it automatically transformed into React.createElement calls, which is what React uses under the hood.

const element = <h1>Hello, world!</h1>;
// Transforms to:
const element = React.createElement('h1', null, 'Hello, world!');

Custom JSX Pragma

This feature allows you to specify a custom function to be used instead of React.createElement. This can be useful if you are using a different library that uses JSX syntax.

/* @jsx customCreateElement */
const element = <h1>Hello, world!</h1>;
// Transforms to:
const element = customCreateElement('h1', null, 'Hello, world!');

Automatic Fragment Support

This feature allows you to use the shorthand syntax for React fragments, which are used to group multiple elements without adding extra nodes to the DOM.

const element = <><h1>Hello, world!</h1><p>This is a paragraph.</p></>;
// Transforms to:
const element = React.createElement(React.Fragment, null, React.createElement('h1', null, 'Hello, world!'), React.createElement('p', null, 'This is a paragraph.'));

Other packages similar to babel-plugin-transform-react-jsx

Keywords

FAQs

Package last updated on 25 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc