@@ -15,7 +15,18 @@ var _wrapStatelessFunction = require('./wrapStatelessFunction');
15
15
var _wrapStatelessFunction2 = _interopRequireDefault ( _wrapStatelessFunction ) ;
16
16
17
17
var 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
+ } ;
19
30
20
31
/**
21
32
* When used as a function.
@@ -28,7 +39,11 @@ var decoratorConstructor = undefined,
28
39
functionConstructor = function ( Component , defaultStyles , options ) {
29
40
var decoratedClass = undefined ;
30
41
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
+ }
32
47
33
48
if ( Component . displayName ) {
34
49
decoratedClass . displayName = Component . displayName ;
0 commit comments