"use client" import { useEffect } from "react" import { addScrollEvent, removeScrollEvent, } from "../components/VirtualizedTable/utils" export function useSynchronizedScroll( element: HTMLDivElement | null, otherElement: HTMLDivElement | null, ) { // Synchronizes the horizontal scroll position of two elements, such as a header and table. useEffect(() => { if (element && otherElement) { addScrollEvent(element, otherElement) } return () => { removeScrollEvent(element) removeScrollEvent(otherElement) } }, [element, otherElement]) }