Skip to content

Commit

Permalink
Merge pull request #357 from wizardzloy/patch-1
Browse files Browse the repository at this point in the history
Use better displayNames for components wrapped into HOC
  • Loading branch information
Semigradsky authored Jul 5, 2016
2 parents 89a2d42 + 9e923dd commit da8f041
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/HOC.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var React = global.React || require('react');
var Mixin = require('./Mixin.js');
module.exports = function (Component) {
return React.createClass({
displayName: 'Formsy(' + getDisplayName(Component) + ')',
mixins: [Mixin],
render: function () {
return React.createElement(Component, {
Expand All @@ -25,3 +26,11 @@ module.exports = function (Component) {
}
});
};

function getDisplayName(Component) {
return (
Component.displayName ||
Component.name ||
(typeof Component === 'string' ? Component : 'Component')
);
}

0 comments on commit da8f041

Please sign in to comment.