0.2.5 • Published 6 years ago

react-display-name v0.2.5

Weekly downloads
280,322
License
MIT
Repository
github
Last release
6 years ago
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:

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)');
@jonahgroup-hvpa/redux-obtain@tomas2d/jeromeprogressmonitor-componentsgraphql-playground-react-auth@kidsagree/uireact-dnd-window-scroll@narwhalosaurus/ui@dxos/messenger-app@dxos/game-applyrahealth-uicore@yuetlooo/uireact-beautifull-dnd-scrollzone@infinitebrahmanuniverse/nolb-react-di@everything-registry/sub-chunk-2551vx-components-reactthemingjitsimeetreactjest-enzyme-matchersjest-snapshotsjest-mock-react-noopilluminati0n-react-yandex-mapshoist-react-staticsiocmaxwells-react-google-maps@webscopeio/graphql-playground-react@wirelineio/appkit@times-components/tracking@times-components/pagination@times-components/provider@times-components/sticky@terraeclipse/crs-cloudinary@treelab/new-react-virtual-kanban@zalastax/nolb-react-di@znemz/debounce-handleradobe-target-hocatroo-frontend-collective-react-dnd-scrollzone@handyai/playground@moneko/react-dnd-scrollzoneui-1hive@layerzerolabs/stargate-ui@loomhq/react-dnd-scrollzone@newtonschool/react-dnd-scrollzoneopentok-react-data-cloneopentok-react-incodeopentok-react-nextjsopentok-react-no-destroyopentok-react-ssropentok-react-vivopentok-react-without-peerdepopentok-rvcopentok-reactopentok-react-c2tscrimshaw-reactreact-adoptreact-chunkreact-context-helpersreact-context-subscriberreact-big-calendar-touch-dndreact-animate-propsreact-bookreader-books-modulereact-better-contextreact-common-kitrodericreact-aperturereact-bem-modreact-curry-componentreact-dom-html-tagsreact-modal-hocreact-memoized-contextreact-mouse-awarereact-jaxreact-inertial-scrollreact-isomorphic-examplereact-intl2react-intl-forkreact-html-metadatareact-inject-firebase-datareact-goodiesreact-dnd-scrollzonereact-dnd-scrollzone-customreact-dnd-scrollzone-patch-react-17react-dnd-scrollzone-remasteredreact-google-maps-swreact-google-maps-tempreact-google-maps-fixedreact-fullscreenablereact-fullscreenable-hocreact-geoinputreact-onenterkeydownppong87-graphql-playground-reactrescapes-react-adoptreprologpristine-appredux-inputsredux-obtainredux-cuberedux-autoloaderreactogglespristine-componentsretabbed
0.2.5

6 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.0

10 years ago

0.1.1

10 years ago

0.0.1

10 years ago