Skip to content

Commit

Permalink
fix: offsetHeight null error (react-component#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
lift46252 committed Jul 3, 2024
1 parent 20e940a commit 6f9d98a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/hooks/useHeights.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -30,10 +29,10 @@ export default function useHeights<T>(
const doCollect = () => {
instanceRef.current.forEach((element, key) => {
if (element && element.offsetParent) {
const htmlElement = findDOMNode<HTMLElement>(element);
const { offsetHeight } = htmlElement;
const { offsetHeight } = element;

if (heightsRef.current.get(key) !== offsetHeight) {
heightsRef.current.set(key, htmlElement.offsetHeight);
heightsRef.current.set(key, offsetHeight);
}
}
});
Expand Down

0 comments on commit 6f9d98a

Please sign in to comment.