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

babel-plugin-transform-react-constant-elements

Package Overview
Dependencies
Maintainers
6
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-react-constant-elements

Treat React JSX elements as value types and hoist them to the highest scope

  • 6.23.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
61K
decreased by-17.31%
Maintainers
6
Weekly downloads
 
Created
Source

babel-plugin-transform-react-constant-elements

Treat React JSX elements as value types and hoist them to the highest scope

Example

In

const Hr = () => {
  return <hr className="hr" />;
};

Out

const _ref = <hr className="hr" />;

const Hr = () => {
  return _ref;
};

Deopts

  • Spread Operator

    <div {...foobar} />
    
  • Refs

    <div ref="foobar" />
    <div ref={node => this.node = node} />
    

Installation

npm install --save-dev babel-plugin-transform-react-constant-elements

Usage

.babelrc

{
  "plugins": ["transform-react-constant-elements"]
}

Via CLI

babel --plugins transform-react-constant-elements script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-react-constant-elements"]
});

References

  • [facebook/react#3226] Optimizing Compiler: Reuse Constant Value Types like ReactElement

Keywords

FAQs

Package last updated on 13 Feb 2017

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