Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/components/grid/Grid.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ describe("Grid", () => {
/>
);

const NewCellComponent = vi.fn(() => null);
const NewCellComponent = vi.fn(() => <div />);

rerender(
<Grid
Expand Down
3 changes: 2 additions & 1 deletion lib/components/grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
useImperativeHandle,
useMemo,
useState,
type ReactElement,
type ReactNode
} from "react";
import { useIsRtl } from "../../core/useIsRtl";
Expand Down Expand Up @@ -36,7 +37,7 @@ export function Grid<
style,
tagName = "div" as TagName,
...rest
}: GridProps<CellProps, TagName>) {
}: GridProps<CellProps, TagName>): ReactElement {
const cellProps = useMemoizedObject(cellPropsUnstable);
const CellComponent = useMemo(
() => memo(CellComponentProp, arePropsEqual),
Expand Down
3 changes: 2 additions & 1 deletion lib/components/grid/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {
ComponentProps,
CSSProperties,
HTMLAttributes,
ReactElement,
ReactNode,
Ref
} from "react";
Expand Down Expand Up @@ -34,7 +35,7 @@ export type GridProps<
rowIndex: number;
style: CSSProperties;
} & CellProps
) => ReactNode;
) => ReactElement;

/**
* Additional props to be passed to the cell-rendering component.
Expand Down
2 changes: 1 addition & 1 deletion lib/components/list/List.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ describe("List", () => {
/>
);

const NewRowComponent = vi.fn(() => null);
const NewRowComponent = vi.fn(() => <div />);

rerender(
<List
Expand Down
3 changes: 2 additions & 1 deletion lib/components/list/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
useImperativeHandle,
useMemo,
useState,
type ReactElement,
type ReactNode
} from "react";
import { useVirtualizer } from "../../core/useVirtualizer";
Expand Down Expand Up @@ -35,7 +36,7 @@ export function List<
tagName = "div" as TagName,
style,
...rest
}: ListProps<RowProps, TagName>) {
}: ListProps<RowProps, TagName>): ReactElement {
const rowProps = useMemoizedObject(rowPropsUnstable);
const RowComponent = useMemo(
() => memo(RowComponentProp, arePropsEqual),
Expand Down
3 changes: 2 additions & 1 deletion lib/components/list/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {
ComponentProps,
CSSProperties,
HTMLAttributes,
ReactElement,
ReactNode,
Ref
} from "react";
Expand Down Expand Up @@ -98,7 +99,7 @@ export type ListProps<
index: number;
style: CSSProperties;
} & RowProps
) => ReactNode;
) => ReactElement;

/**
* Number of items to be rendered in the list.
Expand Down
8 changes: 8 additions & 0 deletions scripts/utils/getPropTypeText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ export function getPropTypeText(prop: PropItem) {
if (!textToFormat && prop.type.name.includes(":")) {
// Edge case where some prop types aren't registered as containing raw TS
textToFormat = prop.type.name;

// List/Grid and rowComponent/cellComponent are annotated with a return type of ReactElement instead of ReactNode
// As a result of this change the generated docs are significantly less readable, so tidy them up here
// See github.com/bvaughn/react-window/issues/875
textToFormat = textToFormat.replace(
"ReactElement<unknown, string | JSXElementConstructor<...>>",
"ReactNode"
);
}

if (!textToFormat) {
Expand Down