File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,18 @@ import extendReactClass from './extendReactClass';
2
2
import wrapStatelessFunction from './wrapStatelessFunction' ;
3
3
4
4
let decoratorConstructor ,
5
- functionConstructor ;
5
+ functionConstructor ,
6
+ isReactComponent ;
7
+
8
+ /**
9
+ * Determines if the given object has the signature of a class that inherits React.Component.
10
+ *
11
+ * @param {* } Component
12
+ * @return {Boolean }
13
+ */
14
+ isReactComponent = ( Component ) => {
15
+ return 'prototype' in Component && typeof Component . prototype . render === 'function' ;
16
+ } ;
6
17
7
18
/**
8
19
* When used as a function.
@@ -15,9 +26,11 @@ let decoratorConstructor,
15
26
functionConstructor = ( Component , defaultStyles , options ) => {
16
27
let decoratedClass ;
17
28
18
- decoratedClass = Component . isReactClass ?
19
- extendReactClass ( Component , defaultStyles , options ) :
20
- wrapStatelessFunction ( Component , defaultStyles , options ) ;
29
+ if ( isReactComponent ( Component ) ) {
30
+ decoratedClass = extendReactClass ( Component , defaultStyles , options ) ;
31
+ } else {
32
+ decoratedClass = wrapStatelessFunction ( Component , defaultStyles , options ) ;
33
+ }
21
34
22
35
if ( Component . displayName ) {
23
36
decoratedClass . displayName = Component . displayName ;
You can’t perform that action at this time.
0 commit comments