mirror of
https://github.com/datahub-project/datahub.git
synced 2025-09-30 03:25:14 +00:00
15 lines
530 B
TypeScript
15 lines
530 B
TypeScript
import { useEffect, useRef, useState } from 'react';
|
|
|
|
export default function useParentContainersTruncation(dataDependency: any) {
|
|
const contentRef = useRef<HTMLDivElement>(null);
|
|
const [isContentTruncated, setAreContainersTruncated] = useState(false);
|
|
|
|
useEffect(() => {
|
|
if (contentRef && contentRef.current && contentRef.current.scrollWidth > contentRef.current.clientWidth) {
|
|
setAreContainersTruncated(true);
|
|
}
|
|
}, [dataDependency]);
|
|
|
|
return { contentRef, isContentTruncated };
|
|
}
|