File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ export const useComposeRef = <T>(...refs: React.Ref<T>[]): React.Ref<T> => {
36
36
} ;
37
37
38
38
export const supportRef = ( nodeOrComponent : any ) : boolean => {
39
+ if ( ! nodeOrComponent ) {
40
+ return false ;
41
+ }
42
+
39
43
// React 19 no need `forwardRef` anymore. So just pass if is a React element.
40
44
if (
41
45
isReactElement ( nodeOrComponent ) &&
Original file line number Diff line number Diff line change @@ -178,6 +178,10 @@ describe('ref', () => {
178
178
expect ( supportRef ( MemoFC ) ) . toBeTruthy ( ) ;
179
179
expect ( supportRef ( holderRef . current . props . children ) ) . toBeTruthy ( ) ;
180
180
} ) ;
181
+
182
+ it ( 'skip null' , ( ) => {
183
+ expect ( supportRef ( null ) ) . toBeFalsy ( ) ;
184
+ } ) ;
181
185
} ) ;
182
186
183
187
describe ( 'nodeSupportRef' , ( ) => {
You can’t perform that action at this time.
0 commit comments