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-reacttheming@dogedollar/ui@docflow/frontend-collective-react-dnd-scrollzone@commercetools/enzyme-extensions@commercetools/jest-enzyme-matchers@commonsswarm/ui@dragonraider5/react-intl@dragonraider5/react-router-query-params@dragonsahead/dragonsahead-uijitsimeetreactjest-enzyme-matchersjest-snapshotsjest-mock-react-noop@moneko/react-dnd-scrollzoneui-1hive@apollographql/graphql-playground-react@aragon/ui@alexkuz/react-yandex-maps@bitcointrade/query-string-hoc@bitcointrade/react-helpers@bitcointrade/react-validity@blossom-labs/rosette-ui@cdmsmith/graphql-playground-react@cbrazn/aragon-ui@cloudflare/style-container@cloudflare/util-testing@0xgabi/ui@0xgabi/1hive-ui@1hive/1hive-ui@1hive/tecommons-ui@42.nl/react-url@4c/react-intl@ackee/lucas@ackee/mateus@ackee/redux-worker@ackee/jerome@codens/codens-react-google-maps@codemayonnaise/react-dnd-scrollzone@conflux-/aragon-ui@handyai/playground@hocs/with-callback-on-change@hocs/with-callback-on-change-while@hocs/with-callback-once@hocs/with-debugger@hocs/with-intersection-observer-props@hocs/with-lifecycle@hocs/with-log@hocs/with-match-media-props@hocs/with-online-status-props@hocs/with-page-visibility-props@hocs/debounce-handler@hocs/omit-props@hocs/prevent-handlers-default@hocs/safe-timers@hocs/throttle-handler@healthfocus/redux-obtain@hocs/with-resize-observer-props@hocs/with-view-layout-props@freedombase/react-intl@inlightmedia/opentok-react@innodata/react-yandex-maps@inst-app/react@layerzerolabs/stargate-ui@loomhq/react-dnd-scrollzone@lunaris-studios/paradigm-universal@lunrdigital/react-tracker@newtonschool/react-dnd-scrollzone@neises/pw-react-dnd-scrollzone@narwhalswap/thegrandbanks-uikit@modern-js-model/reduck-core@kalmar-io/uikit@justin/react-redux-firebase@jkmadison/react-validation-mixin@jaredlunde/react-with-sticky@jaredlunde/react@jpruden/graphql-playground-react@olimsaidov/graphql-playground-react@rearden/graphql-playground-react@ref/react-dnd-scrollzone@pokt-foundation/ui@spotware/react-dnd-scrollzone@render-props/compose@simonghales/frontend-collective-react-dnd-scrollzoneopentok-react-data-cloneopentok-react-incode
0.2.5

6 years ago

0.2.4

7 years ago

0.2.3

8 years ago

0.2.0

9 years ago

0.1.1

9 years ago

0.0.1

10 years ago