We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d2a8db3 commit 850dfdcCopy full SHA for 850dfdc
2 files changed
src/ref.ts
@@ -36,6 +36,10 @@ export const useComposeRef = <T>(...refs: React.Ref<T>[]): React.Ref<T> => {
36
};
37
38
export const supportRef = (nodeOrComponent: any): boolean => {
39
+ if (!nodeOrComponent) {
40
+ return false;
41
+ }
42
+
43
// React 19 no need `forwardRef` anymore. So just pass if is a React element.
44
if (
45
isReactElement(nodeOrComponent) &&
tests/ref.test.tsx
@@ -178,6 +178,10 @@ describe('ref', () => {
178
expect(supportRef(MemoFC)).toBeTruthy();
179
expect(supportRef(holderRef.current.props.children)).toBeTruthy();
180
});
181
182
+ it('skip null', () => {
183
+ expect(supportRef(null)).toBeFalsy();
184
+ });
185
186
187
describe('nodeSupportRef', () => {
0 commit comments