babel-plugin-transform-react-class-displayname

1.0.1 • Public • Published

babel-plugin-transform-react-class-displayname

Babel plugin that injects class' name as displayName property.

Install:

  npm i -D babel-plugin-transform-react-class-displayname

or

  yarn add --dev babel-plugin-transform-react-class-displayname

Usage:

via .babelrc

{
   "plugins": ["transform-react-class-displayname"],
}

via cli

babel --plugins transform-react-class-displayname script.js

Note:

If You want to use this plugin with es2015 preset, you need to install transform class properties plugin

Example:

In:

  const component = class Class1 {

  };

  class Class2 {
   
  }

Out:

  const component = class Class1 {
    static displayName = "Class1";
  };

  class Class2 {
    static displayName = "Class2";
  }

Package Sidebar

Install

npm i babel-plugin-transform-react-class-displayname

Weekly Downloads

3

Version

1.0.1

License

MIT

Last publish

Collaborators

  • krizzu