Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

babel-plugin-transform-react-constant-elements

6.23.0 • Public • Published

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

Via .babelrc (Recommended)

.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

Keywords

install

npm i babel-plugin-transform-react-constant-elements

Downloadsweekly downloads

1,731,945

version

6.23.0

license

MIT

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
  • avatar
  • avatar
Report a vulnerability