File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -20,9 +20,18 @@ export function composeRef<T>(...refs: React.Ref<T>[]): React.Ref<T> {
2020 } ;
2121}
2222
23- export function supportRef ( node : any ) : boolean {
23+ export function supportRef ( nodeOrComponent : any ) : boolean {
24+ // Function component node
25+ if (
26+ nodeOrComponent . type &&
27+ nodeOrComponent . type . prototype &&
28+ ! nodeOrComponent . type . prototype . render
29+ ) {
30+ return false ;
31+ }
32+
2433 // Function component
25- if ( node . type && node . type . prototype && ! node . type . prototype . render ) {
34+ if ( typeof nodeOrComponent === 'function' && ! nodeOrComponent . prototype . render ) {
2635 return false ;
2736 }
2837
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ describe('ref', () => {
2222 < FC />
2323 </ div > ,
2424 ) ;
25+ expect ( supportRef ( FC ) ) . toBeFalsy ( ) ;
2526 expect ( supportRef ( wrapper . props ( ) . children ) ) . toBeFalsy ( ) ;
2627 } ) ;
2728
@@ -32,6 +33,7 @@ describe('ref', () => {
3233 < FRC />
3334 </ div > ,
3435 ) ;
36+ expect ( supportRef ( FRC ) ) . toBeTruthy ( ) ;
3537 expect ( supportRef ( wrapper . props ( ) . children ) ) . toBeTruthy ( ) ;
3638 } ) ;
3739
@@ -48,6 +50,7 @@ describe('ref', () => {
4850 < CC />
4951 </ div > ,
5052 ) ;
53+ expect ( supportRef ( CC ) ) . toBeTruthy ( ) ;
5154 expect ( supportRef ( wrapper . props ( ) . children ) ) . toBeTruthy ( ) ;
5255 } ) ;
5356 } ) ;
You can’t perform that action at this time.
0 commit comments