@babel/plugin-transform-react-display-name

NOTE: This plugin is included in @babel/preset-react

Example

In

  1. var foo = React.createClass({}); // React <= 15
  2. var bar = createReactClass({}); // React 16+

Out

  1. var foo = React.createClass({
  2. displayName: "foo",
  3. }); // React <= 15
  4. var bar = createReactClass({
  5. displayName: "bar",
  6. }); // React 16+

Installation

  1. npm install --save-dev @babel/plugin-transform-react-display-name

Usage

  1. {
  2. "plugins": ["@babel/plugin-transform-react-display-name"]
  3. }

Via CLI

  1. babel --plugins @babel/plugin-transform-react-display-name script.js

Via Node API

  1. require("@babel/core").transformSync("code", {
  2. plugins: ["@babel/plugin-transform-react-display-name"],
  3. });