Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README

This file was deleted.

35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# babel-plugin-transform-react-es6-displayname

Automatically add `displayName` to React components instantiated in ES6 style inheriting from React.Component (ex: `class ComponentName extends React.Component`)

## Installation

```sh
$ npm install babel-plugin-transform-react-es6-displayname
```

## Usage

### Via `.babelrc` (Recommended)

**.babelrc**

```js
{
"plugins": ["transform-react-es6-displayname"]
}
```

### Via CLI

```sh
$ babel --plugins transform-react-es6-displayname script.js
```

### Via Node API

```javascript
require("babel-core").transform("code", {
plugins: ["transform-react-es6-displayname"]
});
```
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function addDisplayName (t) {
)
)
) {
this.insertAfter([
(t.isExportNamedDeclaration(this.parentPath.node) ? this.parentPath : this).insertAfter([
t.expressionStatement(t.assignmentExpression(
'=',
t.memberExpression(this.node.id, t.identifier('displayName')),
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-plugin-transform-react-es6-displayname",
"version": "1.0.0-beta1.3",
"version": "1.0.0-beta1.4",
"description": "Babel transform to add the displayName property to component classes",
"main": "index.js",
"scripts": {
Expand All @@ -18,7 +18,10 @@
"react",
"displayName"
],
"author": "Nathan Marks <[email protected]> (http://nathanmarks.io)",
"authors": [
"Nathan Marks <[email protected]> (http://nathanmarks.io)",
"Dmitri Farkov <[email protected]> (http://github.com/dmitrif)"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/nathanmarks/babel-plugin-transform-react-es6-displayname/issues"
Expand Down