babel-plugin-transform-react-infer-display-name
Add displayName
to React components (descendants of React.Component
and SFCs).
React.Component
Example
In
Component { superprops; thisstate = counter: 0 ; } { return <div> thisstatecounter </div> ; }
Out
Component { superprops; thisstate = counter: 0 ; } { return <div> thisstatecounter </div> ; }StatefulCounterdisplayName = 'StatefulCounter';
SFC Example
In
{ return <div> counter </div> ;}
Out
{ return <div> counter </div> ;}PureCounterdisplayName = 'PureCounter';
Installation
npm install --save-dev babel-plugin-transform-react-infer-display-name
Usage
.babelrc
(Recommended)
Via .babelrc
Via CLI
babel --plugins transform-react-infer-display-name script.js
Via Node API
;
Running Tests
from the root directory
npm install --global mochamocha