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> => {
3636} ;
3737
3838export const supportRef = ( nodeOrComponent : any ) : boolean => {
39+ if ( ! nodeOrComponent ) {
40+ return false ;
41+ }
42+
3943 // React 19 no need `forwardRef` anymore. So just pass if is a React element.
4044 if (
4145 isReactElement ( nodeOrComponent ) &&
Original file line number Diff line number Diff line change @@ -178,6 +178,10 @@ describe('ref', () => {
178178 expect ( supportRef ( MemoFC ) ) . toBeTruthy ( ) ;
179179 expect ( supportRef ( holderRef . current . props . children ) ) . toBeTruthy ( ) ;
180180 } ) ;
181+
182+ it ( 'skip null' , ( ) => {
183+ expect ( supportRef ( null ) ) . toBeFalsy ( ) ;
184+ } ) ;
181185 } ) ;
182186
183187 describe ( 'nodeSupportRef' , ( ) => {
You can’t perform that action at this time.
0 commit comments