feat: fast observers

This commit is contained in:
TrèsAbhi committed 2024-07-06 20:32:41 -05:00
1 parent b965893bfc
commit 33c67b9416
2 files changed
+48 -5

No files matched your search

@@ -1,10 +1,26 @@
import { Skeleton, Table } from '@radix-ui/themes';
import { times } from 'lodash';
import { useEffect, useRef } from 'react';
import { tankPerformanceSortTypeNamesArray } from '../../../../stores/tankPerformanceSort';
export function RowLoader() {
interface RowLoaderProps {
onIntersection?: () => void;
}
export function RowLoader({ onIntersection }: RowLoaderProps) {
const row = useRef<HTMLTableRowElement>(null);
useEffect(() => {
if (!onIntersection || !row.current) return;
const observer = new IntersectionObserver(onIntersection);
observer.observe(row.current);
return () => observer.disconnect();
}, []);
return (
<Table.Row>
<Table.Row ref={row}>
<Table.RowHeaderCell align="center">
<Skeleton height="100%" width="128px" />
</Table.RowHeaderCell>