Skip to content

Commit

Permalink
minor typing improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
onderonur committed Nov 3, 2024
1 parent 71ef76e commit 032711e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function InfiniteListWithReverseHozirontalScroll() {
rootMargin: '0px 0px 0px 400px',
});

const scrollableRootRef = useRef<React.ElementRef<'div'> | null>(null);
const scrollableRootRef = useRef<React.ComponentRef<'div'> | null>(null);
const lastScrollDistanceToRightRef = useRef<number>();

const reversedItems = useMemo(() => [...items].reverse(), [items]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function InfiniteListWithReverseVerticalScroll() {
rootMargin: '400px 0px 0px 0px',
});

const scrollableRootRef = useRef<React.ElementRef<'div'> | null>(null);
const scrollableRootRef = useRef<React.ComponentRef<'div'> | null>(null);
const lastScrollDistanceToBottomRef = useRef<number>();

const reversedItems = useMemo(() => [...items].reverse(), [items]);
Expand Down
9 changes: 6 additions & 3 deletions apps/demo/src/components/list.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { forwardRef } from 'react';

type ListProps = React.PropsWithChildren & {
type ListProps = {
direction?: 'vertical' | 'horizontal';
children: React.ReactNode;
};

export function List({ direction, ...rest }: ListProps) {
Expand All @@ -13,9 +14,11 @@ export function List({ direction, ...rest }: ListProps) {
);
}

type ListItemProps = React.PropsWithChildren;
type ListItemProps = {
children: React.ReactNode;
};

export const ListItem = forwardRef<React.ElementRef<'li'>, ListItemProps>(
export const ListItem = forwardRef<React.ComponentRef<'li'>, ListItemProps>(
function ListItem(props, ref) {
return <li ref={ref} className="m-1 border bg-slate-200 p-2" {...props} />;
},
Expand Down

0 comments on commit 032711e

Please sign in to comment.