16 lines
345 B
TypeScript
16 lines
345 B
TypeScript
import React from 'react';
|
|
|
|
export function useInitialCardHeight(
|
|
cardRef: React.MutableRefObject<HTMLDivElement>,
|
|
) {
|
|
const heightRef = React.useRef<number>(0);
|
|
|
|
React.useEffect(() => {
|
|
if (heightRef.current <= 0 && cardRef.current) {
|
|
heightRef.current = cardRef.current.clientHeight;
|
|
}
|
|
});
|
|
|
|
return heightRef.current;
|
|
}
|