react-display-name

WebJar for react-display-name

License

License

MIT
Categories

Categories

React User Interface Web Frameworks
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

react-display-name
Last Version

Last Version

0.2.5
Release Date

Release Date

Type

Type

jar
Description

Description

react-display-name
WebJar for react-display-name
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/jurassix/react-display-name

Download react-display-name

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/react-display-name/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>react-display-name</artifactId>
    <version>0.2.5</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/react-display-name/
implementation 'org.webjars.npm:react-display-name:0.2.5'
// https://jarcasting.com/artifacts/org.webjars.npm/react-display-name/
implementation ("org.webjars.npm:react-display-name:0.2.5")
'org.webjars.npm:react-display-name:jar:0.2.5'
<dependency org="org.webjars.npm" name="react-display-name" rev="0.2.5">
  <artifact name="react-display-name" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='react-display-name', version='0.2.5')
)
libraryDependencies += "org.webjars.npm" % "react-display-name" % "0.2.5"
[org.webjars.npm/react-display-name "0.2.5"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.
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)');

Versions

Version
0.2.5
0.2.4