Socket
Socket
Sign inDemoInstall

babel-plugin-transform-react-create-element

Package Overview
Dependencies
18
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    babel-plugin-transform-react-create-element

Shorten JSX React.createElement calls using a local variable.


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

babel-plugin-transform-react-create-element

Shorten JSX React.createElement calls using a local variable.

Compiles

import React from 'react';

const Component = () => (
  <div>Hello, World!</div>
);

to

import React from 'react';

const _createElement = React.createElement;

const Component = () => (
  _createElement('div', {}, 'Hello, World!')
);

instead of

import React from 'react';

const Component = () => (
  React.createElement('div', {}, 'Hello, World!')
);

How?

Install via npm install -D babel-plugin-transform-react-create-element or yarn add -D babel-plugin-transform-react-create-element.

In your .babelrc:

{
  "plugins": [
    "babel-plugin-transform-react-create-element",
  ]
}

It works by translating any found calls to React.createElement to use the newly inserted local variable instead.

As such, it automatically respects any existing JSX pragmas in the file and does not interfer with their use.

Why?

Performance. In particular in conjunction with the way webpack transforms imports.

Also created to solve https://github.com/facebook/create-react-app/issues/5435.

License

MIT

Loosely based on https://github.com/facebook/create-react-app/pull/6219.

FAQs

Last updated on 20 Apr 2020

Did you know?

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc