File tree Expand file tree Collapse file tree 7 files changed +18
-6
lines changed Expand file tree Collapse file tree 7 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ describe("Grid", () => {
168168 />
169169 ) ;
170170
171- const NewCellComponent = vi . fn ( ( ) => null ) ;
171+ const NewCellComponent = vi . fn ( ( ) => < div /> ) ;
172172
173173 rerender (
174174 < Grid
Original file line number Diff line number Diff line change 55 useImperativeHandle ,
66 useMemo ,
77 useState ,
8+ type ReactElement ,
89 type ReactNode
910} from "react" ;
1011import { useIsRtl } from "../../core/useIsRtl" ;
@@ -36,7 +37,7 @@ export function Grid<
3637 style,
3738 tagName = "div" as TagName ,
3839 ...rest
39- } : GridProps < CellProps , TagName > ) {
40+ } : GridProps < CellProps , TagName > ) : ReactElement {
4041 const cellProps = useMemoizedObject ( cellPropsUnstable ) ;
4142 const CellComponent = useMemo (
4243 ( ) => memo ( CellComponentProp , arePropsEqual ) ,
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import type {
22 ComponentProps ,
33 CSSProperties ,
44 HTMLAttributes ,
5+ ReactElement ,
56 ReactNode ,
67 Ref
78} from "react" ;
@@ -34,7 +35,7 @@ export type GridProps<
3435 rowIndex : number ;
3536 style : CSSProperties ;
3637 } & CellProps
37- ) => ReactNode ;
38+ ) => ReactElement ;
3839
3940 /**
4041 * Additional props to be passed to the cell-rendering component.
Original file line number Diff line number Diff line change @@ -181,7 +181,7 @@ describe("List", () => {
181181 />
182182 ) ;
183183
184- const NewRowComponent = vi . fn ( ( ) => null ) ;
184+ const NewRowComponent = vi . fn ( ( ) => < div /> ) ;
185185
186186 rerender (
187187 < List
Original file line number Diff line number Diff line change 55 useImperativeHandle ,
66 useMemo ,
77 useState ,
8+ type ReactElement ,
89 type ReactNode
910} from "react" ;
1011import { useVirtualizer } from "../../core/useVirtualizer" ;
@@ -35,7 +36,7 @@ export function List<
3536 tagName = "div" as TagName ,
3637 style,
3738 ...rest
38- } : ListProps < RowProps , TagName > ) {
39+ } : ListProps < RowProps , TagName > ) : ReactElement {
3940 const rowProps = useMemoizedObject ( rowPropsUnstable ) ;
4041 const RowComponent = useMemo (
4142 ( ) => memo ( RowComponentProp , arePropsEqual ) ,
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import type {
22 ComponentProps ,
33 CSSProperties ,
44 HTMLAttributes ,
5+ ReactElement ,
56 ReactNode ,
67 Ref
78} from "react" ;
@@ -98,7 +99,7 @@ export type ListProps<
9899 index : number ;
99100 style : CSSProperties ;
100101 } & RowProps
101- ) => ReactNode ;
102+ ) => ReactElement ;
102103
103104 /**
104105 * Number of items to be rendered in the list.
Original file line number Diff line number Diff line change @@ -5,6 +5,14 @@ export function getPropTypeText(prop: PropItem) {
55 if ( ! textToFormat && prop . type . name . includes ( ":" ) ) {
66 // Edge case where some prop types aren't registered as containing raw TS
77 textToFormat = prop . type . name ;
8+
9+ // List/Grid and rowComponent/cellComponent are annotated with a return type of ReactElement instead of ReactNode
10+ // As a result of this change the generated docs are significantly less readable, so tidy them up here
11+ // See github.com/bvaughn/react-window/issues/875
12+ textToFormat = textToFormat . replace (
13+ "ReactElement<unknown, string | JSXElementConstructor<...>>" ,
14+ "ReactNode"
15+ ) ;
816 }
917
1018 if ( ! textToFormat ) {
You can’t perform that action at this time.
0 commit comments