react-display-name
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -5,5 +5,5 @@ 'use strict'; | ||
var getDisplayName = function getDisplayName(Component) { | ||
return Component.displayName || Component.name || 'Component'; | ||
return Component.displayName || Component.name || (typeof Component === 'string' ? Component : 'Component'); | ||
}; | ||
exports.default = getDisplayName; |
{ | ||
"name": "react-display-name", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "utility to return a react components display name", | ||
@@ -30,20 +30,22 @@ "main": "./lib/getDisplayName.js", | ||
"devDependencies": { | ||
"babel": "^6.3.26", | ||
"babel-cli": "^6.4.0", | ||
"babel-core": "^6.4.0", | ||
"babel-eslint": "^4.1.6", | ||
"babel-loader": "^6.2.1", | ||
"babel-preset-es2015-loose": "^6.1.4", | ||
"babel-preset-react": "^6.3.13", | ||
"babel-preset-stage-0": "^6.3.13", | ||
"babelify": "^6.2.0", | ||
"chai": "^3.3.0", | ||
"eslint": "^1.1.0", | ||
"eslint-config-airbnb": "0.0.8", | ||
"eslint-plugin-react": "^3.3.0", | ||
"babel": "^6.5.2", | ||
"babel-cli": "^6.7.7", | ||
"babel-core": "^6.7.7", | ||
"babel-eslint": "^6.0.4", | ||
"babel-loader": "^6.2.4", | ||
"babel-preset-es2015": "^6.6.0", | ||
"babel-preset-es2015-loose": "^7.0.0", | ||
"babel-preset-react": "^6.5.0", | ||
"babel-preset-stage-0": "^6.5.0", | ||
"chai": "^3.5.0", | ||
"eslint": "^2.8.0", | ||
"eslint-config-airbnb": "8.0.0", | ||
"eslint-plugin-import": "^1.6.1", | ||
"eslint-plugin-jsx-a11y": "^1.0.3", | ||
"eslint-plugin-react": "^5.0.1", | ||
"mkdirp": "^0.5.1", | ||
"mocha": "^2.3.3", | ||
"react": "^0.14.0-rc1", | ||
"rimraf": "^2.4.3" | ||
"mocha": "^2.4.5", | ||
"react": "^15.0.1", | ||
"rimraf": "^2.5.2" | ||
} | ||
} |
@@ -1,3 +0,3 @@ | ||
import {expect} from 'chai'; | ||
import React, {Component} from 'react'; | ||
import { expect } from 'chai'; | ||
import React, { Component } from 'react'; | ||
import getDisplayName from '../getDisplayName'; | ||
@@ -17,3 +17,3 @@ | ||
class Simple extends Component { | ||
static displayName = 'Simple'; | ||
static displayName = 'Simple' | ||
render() { | ||
@@ -25,4 +25,7 @@ return <div></div>; | ||
}); | ||
it('returns display name of html string component', () => { | ||
expect(getDisplayName('input')).to.equal('input'); | ||
}); | ||
it('returns display name for a stateless component', () => { | ||
const Simple = (props) => <div></div> | ||
const Simple = () => <div></div>; | ||
@@ -47,3 +50,3 @@ expect(getDisplayName(Simple)).to.equal('Simple'); | ||
class Container extends Component { | ||
static displayName = `Container(${getDisplayName(WrappedComponent)})`; | ||
static displayName = `Container(${getDisplayName(WrappedComponent)})` | ||
render() { | ||
@@ -56,3 +59,3 @@ return ( | ||
return Container; | ||
} | ||
}; | ||
@@ -71,3 +74,3 @@ class HelloWorld extends Component { | ||
expect(HelloWorldPrime.displayName).to.equal('Container(HelloWorld)'); | ||
}) | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5326
9
70
19