From 4209babb476f84e011fe1df361591a7c677a4485 Mon Sep 17 00:00:00 2001 From: jack zhang <1098626505@qq.com> Date: Mon, 13 Nov 2023 17:49:24 +0800 Subject: [PATCH] fix: antd table ref bug (#3029) --- .../core/client/src/schema-component/hooks/useTableSize.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/client/src/schema-component/hooks/useTableSize.ts b/packages/core/client/src/schema-component/hooks/useTableSize.ts index 6a5a41a1e..4b9b02153 100644 --- a/packages/core/client/src/schema-component/hooks/useTableSize.ts +++ b/packages/core/client/src/schema-component/hooks/useTableSize.ts @@ -3,7 +3,7 @@ import { useCallback, useRef, useState } from 'react'; export const useTableSize = () => { const [height, setTableHeight] = useState(0); const [width, setTableWidth] = useState(0); - const elementRef = useRef(); + const elementRef = useRef(null); const calcTableSize = useCallback(() => { if (!elementRef.current) return; @@ -21,7 +21,7 @@ export const useTableSize = () => { }, []); const tableSizeRefCallback: React.RefCallback = (ref) => { - elementRef.current = ref; + elementRef.current = ref && ref.children ? (ref.children[0] as HTMLDivElement) : null; calcTableSize(); };