Merge pull request #357 from wizardzloy/patch-1

Use better displayNames for components wrapped into HOC
This commit is contained in:
Dmitry Semigradsky 2016-07-05 10:41:16 +03:00 committed by GitHub
commit da8f041eca
1 changed files with 9 additions and 0 deletions

View File

@ -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, {
@ -25,3 +26,11 @@ module.exports = function (Component) {
}
});
};
function getDisplayName(Component) {
return (
Component.displayName ||
Component.name ||
(typeof Component === 'string' ? Component : 'Component')
);
}