babel-plugin-transform-jsx-memo

0.1.4 • Public • Published

babel-plugin-transform-jsx-memo

Memorize the JSX element.

Example

In

import { createElement } from 'react';

export default function Foo(props) {
  const { message } = props;
  return (
    <div>
      Demo:
      <p x-memo>hello {message}</p>
    </div>
  );
}

Out

import { createJSXMemo as __create_jsx_memo__ } from "babel-plugin-transform-jsx-memo/lib/runtime";
import { createElement } from 'react';
export default function Foo(props) {
  const {
    message
  } = props;
  return <div>
      Demo:
      {__create_jsx_memo__(() => <p>hello {message}</p>, 0)}
    </div>;
}

Installation

$ npm install babel-plugin-transform-jsx-memo

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["transform-jsx-memo"]
}

Via CLI

$ babel --plugins transform-jsx-memo script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-jsx-memo"]
});

Readme

Keywords

Package Sidebar

Install

npm i babel-plugin-transform-jsx-memo

Weekly Downloads

496

Version

0.1.4

License

none

Unpacked Size

8.37 kB

Total Files

10

Last publish

Collaborators

  • zeroling