feat: memoize row loader

This commit is contained in:
TrèsAbhi committed 2024-07-07 18:48:32 -05:00
1 parent cc51f660d4
commit b556f5f7e8
1 file changed
+3 -3
@@ -1,6 +1,6 @@
import { Skeleton, Table } from '@radix-ui/themes'; import { Skeleton, Table } from '@radix-ui/themes';
import { times } from 'lodash'; import { times } from 'lodash';
import { useRef } from 'react'; import { memo, useRef } from 'react';
import { useIntersection } from '../../../../hooks/useIntersection'; import { useIntersection } from '../../../../hooks/useIntersection';
import { tankPerformanceSortTypeNamesArray } from '../../../../stores/tankPerformanceSort'; import { tankPerformanceSortTypeNamesArray } from '../../../../stores/tankPerformanceSort';
@@ -8,7 +8,7 @@ interface RowLoaderProps {
onIntersection?: () => void; onIntersection?: () => void;
} }
export function RowLoader({ onIntersection }: RowLoaderProps) { export const RowLoader = memo<RowLoaderProps>(({ onIntersection }) => {
const row = useRef<HTMLTableRowElement>(null); const row = useRef<HTMLTableRowElement>(null);
useIntersection(() => onIntersection?.(), row, { useIntersection(() => onIntersection?.(), row, {
@@ -28,4 +28,4 @@ export function RowLoader({ onIntersection }: RowLoaderProps) {
))} ))}
</Table.Row> </Table.Row>
); );
} });