@@ -15,7 +15,18 @@ var _wrapStatelessFunction = require('./wrapStatelessFunction');
1515var _wrapStatelessFunction2 = _interopRequireDefault ( _wrapStatelessFunction ) ;
1616
1717var decoratorConstructor = undefined ,
18- functionConstructor = undefined ;
18+ functionConstructor = undefined ,
19+ isReactComponent = undefined ;
20+
21+ /**
22+ * Determines if the given object has the signature of a class that inherits React.Component.
23+ *
24+ * @param {* } Component
25+ * @return {Boolean }
26+ */
27+ isReactComponent = function ( Component ) {
28+ return 'prototype' in Component && typeof Component . prototype . render === 'function' ;
29+ } ;
1930
2031/**
2132 * When used as a function.
@@ -28,7 +39,11 @@ var decoratorConstructor = undefined,
2839functionConstructor = function ( Component , defaultStyles , options ) {
2940 var decoratedClass = undefined ;
3041
31- decoratedClass = Component . isReactClass ? ( 0 , _extendReactClass2 [ 'default' ] ) ( Component , defaultStyles , options ) : ( 0 , _wrapStatelessFunction2 [ 'default' ] ) ( Component , defaultStyles , options ) ;
42+ if ( isReactComponent ( Component ) ) {
43+ decoratedClass = ( 0 , _extendReactClass2 [ 'default' ] ) ( Component , defaultStyles , options ) ;
44+ } else {
45+ decoratedClass = ( 0 , _wrapStatelessFunction2 [ 'default' ] ) ( Component , defaultStyles , options ) ;
46+ }
3247
3348 if ( Component . displayName ) {
3449 decoratedClass . displayName = Component . displayName ;
0 commit comments