Socket
Socket
Sign inDemoInstall

babel-plugin-transform-react-constant-elements

Package Overview
Dependencies
3
Maintainers
6
Versions
34
Alerts
File Explorer

Advanced tools

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


Version published
Weekly downloads
59K
decreased by-16.08%
Maintainers
6
Install size
2.23 MB
Created
Weekly downloads
 

Readme

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

Last updated on 13 Feb 2017

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc