1.0.1 • Published 7 years ago

babel-plugin-transform-react-class-displayname v1.0.1

Weekly downloads
1,583
License
MIT
Repository
github
Last release
7 years ago

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";
  }