Skip to content

Commit

Permalink
refactor: virtua item type
Browse files Browse the repository at this point in the history
  • Loading branch information
aeharding committed Nov 17, 2024
1 parent 5993a0d commit d41fd8b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
1 change: 0 additions & 1 deletion src/features/comment/inTree/Comments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,6 @@ export default function Comments({
}
ref={virtuaRef}
style={{ height: "100%" }}
// @ts-expect-error Virtua types not updated for forwardRef-less components
item={IndexedVirtuaItem}

Check failure on line 519 in src/features/comment/inTree/Comments.tsx

View workflow job for this annotation

GitHub Actions / ci

Type '({ index, ...rest }: CustomItemComponentProps) => Element' is not assignable to type 'keyof IntrinsicElements | CustomItemComponent | undefined'.
overscan={1}
onScroll={(offset) => {
Expand Down
16 changes: 3 additions & 13 deletions src/helpers/virtua.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
import { CustomItemComponentProps } from "virtua";

interface IndexedVirtuaItemProps extends CustomItemComponentProps {
ref: React.RefObject<HTMLDivElement>;
}

/**
* Add data-index to each item for programmatic scrolling
*/
export function IndexedVirtuaItem({
children,
index,
style,
ref,
}: IndexedVirtuaItemProps) {
return (
<div ref={ref} style={style} data-index={index}>
{children}
</div>
);
...rest
}: CustomItemComponentProps) {
return <div data-index={index} {...rest} />;
}

0 comments on commit d41fd8b

Please sign in to comment.