Skip to content

Fix displayName <Unknown /> in react dev tools #335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DateTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var assign = require('object-assign'),

var TYPES = PropTypes;
var Datetime = createClass({
displayName: 'DateTime',
propTypes: {
// value: TYPES.object | TYPES.string,
// defaultValue: TYPES.object | TYPES.string,
Expand Down
50 changes: 47 additions & 3 deletions dist/react-datetime.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ return /******/ (function(modules) { // webpackBootstrap

var TYPES = PropTypes;
var Datetime = createClass({
displayName: 'DateTime',
propTypes: {
// value: TYPES.object | TYPES.string,
// defaultValue: TYPES.object | TYPES.string,
Expand Down Expand Up @@ -757,6 +758,10 @@ return /******/ (function(modules) { // webpackBootstrap
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.prependListener = noop;
process.prependOnceListener = noop;

process.listeners = function (name) { return [] }

process.binding = function (name) {
throw new Error('process.binding is not supported');
Expand Down Expand Up @@ -1095,6 +1100,20 @@ return /******/ (function(modules) { // webpackBootstrap
return emptyFunction.thatReturnsNull;
}

for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
var checker = arrayOfTypeCheckers[i];
if (typeof checker !== 'function') {
warning(
false,
'Invalid argument supplid to oneOfType. Expected an array of check functions, but ' +
'received %s at index %s.',
getPostfixForTypeWarning(checker),
i
);
return emptyFunction.thatReturnsNull;
}
}

function validate(props, propName, componentName, location, propFullName) {
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
var checker = arrayOfTypeCheckers[i];
Expand Down Expand Up @@ -1227,6 +1246,9 @@ return /******/ (function(modules) { // webpackBootstrap
// This handles more types than `getPropType`. Only used for error messages.
// See `createPrimitiveTypeChecker`.
function getPreciseType(propValue) {
if (typeof propValue === 'undefined' || propValue === null) {
return '' + propValue;
}
var propType = getPropType(propValue);
if (propType === 'object') {
if (propValue instanceof Date) {
Expand All @@ -1238,6 +1260,23 @@ return /******/ (function(modules) { // webpackBootstrap
return propType;
}

// Returns a string that is postfixed to a warning about an invalid type.
// For example, "undefined" or "of type array"
function getPostfixForTypeWarning(value) {
var type = getPreciseType(value);
switch (type) {
case 'array':
case 'object':
return 'an ' + type;
case 'boolean':
case 'date':
case 'regexp':
return 'a ' + type;
default:
return type;
}
}

// Returns class name of the object, if any.
function getClassName(propValue) {
if (!propValue.constructor || !propValue.constructor.name) {
Expand Down Expand Up @@ -1535,11 +1574,14 @@ return /******/ (function(modules) { // webpackBootstrap

var emptyFunction = __webpack_require__(5);
var invariant = __webpack_require__(6);
var ReactPropTypesSecret = __webpack_require__(8);

module.exports = function() {
// Important!
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
function shim() {
function shim(props, propName, componentName, location, propFullName, secret) {
if (secret === ReactPropTypesSecret) {
// It is still safe when called from React.
return;
}
invariant(
false,
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
Expand All @@ -1551,6 +1593,8 @@ return /******/ (function(modules) { // webpackBootstrap
function getShim() {
return shim;
};
// Important!
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
var ReactPropTypes = {
array: shim,
bool: shim,
Expand Down
4 changes: 2 additions & 2 deletions dist/react-datetime.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/react-datetime.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/datetime.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import utils from './testUtils';
describe('Datetime', () => {
it('create component', () => {
const component = utils.createDatetime({});

expect(component.name()).toEqual('DateTime');
expect(component).toBeDefined();
expect(component.find('.rdt > .form-control').length).toEqual(1);
expect(component.find('.rdt > .rdtPicker').length).toEqual(1);
Expand Down