From 6f9d98a33920c102d5003d36ee3271144c3eaa78 Mon Sep 17 00:00:00 2001 From: lift46252 Date: Wed, 3 Jul 2024 10:09:55 +0300 Subject: [PATCH] fix: offsetHeight null error (#259) --- src/hooks/useHeights.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/hooks/useHeights.tsx b/src/hooks/useHeights.tsx index ad45d4a..e630f9d 100644 --- a/src/hooks/useHeights.tsx +++ b/src/hooks/useHeights.tsx @@ -1,6 +1,5 @@ import * as React from 'react'; import { useRef, useEffect } from 'react'; -import findDOMNode from 'rc-util/lib/Dom/findDOMNode'; import raf from 'rc-util/lib/raf'; import type { GetKey } from '../interface'; import CacheMap from '../utils/CacheMap'; @@ -30,10 +29,10 @@ export default function useHeights( const doCollect = () => { instanceRef.current.forEach((element, key) => { if (element && element.offsetParent) { - const htmlElement = findDOMNode(element); - const { offsetHeight } = htmlElement; + const { offsetHeight } = element; + if (heightsRef.current.get(key) !== offsetHeight) { - heightsRef.current.set(key, htmlElement.offsetHeight); + heightsRef.current.set(key, offsetHeight); } } });