# babel-plugin-transform-react-infer-display-name

> A Babel preset for adding `displayName` to React components (descendants of `React.Component` and SFCs).

Latest version **0.1.11** (published 2017-10-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-transform-react-infer-display-name
pnpm add babel-plugin-transform-react-infer-display-name
yarn add babel-plugin-transform-react-infer-display-name
bun add babel-plugin-transform-react-infer-display-name
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.11 |
| Published | 2017-10-08 |
| First published | 2017-10-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Gabe Lyons |
| Maintainers | ljharb, gabe-lyons |
| Keywords | babel, babel-plugin, jsx, react |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-transform-react-infer-display-name
- Repository: https://github.com/airbnb/babel-plugin-transform-react-infer-display-name
- Homepage: https://github.com/airbnb/babel-plugin-transform-react-infer-display-name#readme
- Issues: https://github.com/airbnb/babel-plugin-transform-react-infer-display-name/issues
- npm.io page: https://npm.io/package/babel-plugin-transform-react-infer-display-name

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.1.11 (latest) — 2017-10-08

## README

# babel-plugin-transform-react-infer-display-name

Add `displayName` to React components (descendants of `React.Component` and SFCs).

## `React.Component` Example

**In**

```js
export class StatefulCounter extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      counter: 0,
    };
  }

  render() {
    return (
      <div>
        {this.state.counter}
      </div>
    );
  }
}
```

**Out**

```js
export class StatefulCounter extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      counter: 0,
    };
  }

  render() {
    return (
      <div>
        {this.state.counter}
      </div>
    );
  }
}
StatefulCounter.displayName = 'StatefulCounter';
```

## SFC Example

**In**

```js
export function PureCounter({ counter }) {
  return (
    <div>
      {counter}
    </div>
  );
}
```

**Out**

```js
export function PureCounter({ counter }) {
  return (
    <div>
      {counter}
    </div>
  );
}
PureCounter.displayName = 'PureCounter';
```

## Installation

```sh
npm install --save-dev babel-plugin-transform-react-infer-display-name
```

## Usage

### Via `.babelrc` (Recommended)

**.babelrc**

```json
{
  "plugins": ["transform-react-infer-display-name"]
}
```

### Via CLI

```sh
babel --plugins transform-react-infer-display-name script.js
```

### Via Node API

```javascript
require("babel-core").transform("code", {
  plugins: ["transform-react-infer-display-name"]
});
```

## Running Tests

from the root directory

```sh
npm install --global mocha
mocha
```

---
_Source: https://npm.io/package/babel-plugin-transform-react-infer-display-name · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
