# react-display-name

> utility to return a react components display name

Latest version **0.2.5** (published 2019-12-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-display-name
pnpm add react-display-name
yarn add react-display-name
bun add react-display-name
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.5 |
| Published | 2019-12-01 |
| First published | 2015-10-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 59 |
| Author | jurassix |
| Maintainers | jurassix |
| Keywords | react, redux, getDisplayName |

## Links

- npm: https://www.npmjs.com/package/react-display-name
- Repository: https://github.com/jurassix/react-display-name
- Homepage: https://github.com/jurassix/react-display-name#readme
- Issues: https://github.com/jurassix/react-display-name/issues
- npm.io page: https://npm.io/package/react-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.2.5 (latest) — 2019-12-01
- 0.2.4 — 2018-04-13
- 0.2.3 — 2017-07-31
- 0.2.0 — 2016-04-28
- 0.1.1 — 2016-01-13
- 0.0.1 — 2015-10-07

## README

```javascript
npm install --save react-display-name
```

Get the displayName from a Component. This is a common pattern with React Higher Order Components (HoCs). This is a simple reusable utility to get the name of a component.

Usage:

```javascript
import {expect} from 'chai';
import React, {Component} from 'react';
import getDisplayName from 'react-display-name';

const container = (WrappedComponent) => {
  class Container extends Component {
    static displayName = `Container(${getDisplayName(WrappedComponent)})`;
    render() {
      return (
        <WrappedComponent />
      );
    }
  }
  return Container;
}

class HelloWorld extends Component {
  render() {
    return (
      <div>Hello</div>
    );
  }
}

const HelloWorldPrime = container(HelloWorld);

expect(getDisplayName(HelloWorldPrime)).to.equal('Container(HelloWorld)');
expect(HelloWorldPrime.displayName).to.equal('Container(HelloWorld)');
```

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