mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-02 19:43:20 +08:00
Add "List" to TypeDefinitions for react-virtualized (#13965)
* Add List to TypeDefinitions for react-virtualized * Fix header for react-virtualized Type Definitions * Make the ListProps interface follow the structure of the VirtualScrollProps interface; avoid using "any" as our props
This commit is contained in:
committed by
Sheetal Nandi
parent
f011d2dc0f
commit
5bc1b9fb83
24
react-virtualized/index.d.ts
vendored
24
react-virtualized/index.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
// Type definitions for react-virtualized
|
||||
// Type definitions for react-virtualized 8.9.0
|
||||
// Project: https://github.com/bvaughn/react-virtualized
|
||||
// Definitions by: Ian Ker-Seymer <https://github.com/ianks>
|
||||
// Definitions by: Andrew de Waal <https://github.com/andrewdewaal>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="react" />
|
||||
@@ -50,6 +50,26 @@ declare module "react-virtualized" {
|
||||
type GridProps = any;
|
||||
export class Grid extends React.Component<GridProps, {}> { }
|
||||
|
||||
interface ListProps {
|
||||
className?: string;
|
||||
autoHeight?: boolean;
|
||||
estimatedRowSize?: number;
|
||||
height: number;
|
||||
noRowsRenderer?: Function;
|
||||
onRowsRendered?: (info: { overscanStartIndex: number, overscanStopIndex: number, startIndex: number, stopIndex: number }) => void;
|
||||
onScroll?: (info: { clientHeight: number, scrollHeight: number, scrollTop: number }) => void;
|
||||
overscanRowCount?: number;
|
||||
rowHeight: number | ((info: { index: number }) => number);
|
||||
rowRenderer: (info: { index: number, isScrolling: boolean }) => React.ReactNode;
|
||||
rowCount: number;
|
||||
scrollToAlignment?: string;
|
||||
scrollToIndex?: number;
|
||||
scrollTop?: number;
|
||||
style?: React.CSSProperties;
|
||||
tabIndex?: number;
|
||||
width: number;
|
||||
}
|
||||
export class List extends React.Component<ListProps, {}> { }
|
||||
|
||||
/*
|
||||
* Higher-Order Components
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
InfiniteLoader,
|
||||
ScrollSync,
|
||||
WindowScroller,
|
||||
List
|
||||
} from "react-virtualized";
|
||||
|
||||
/*
|
||||
@@ -107,6 +108,26 @@ function GridTest() {
|
||||
);
|
||||
}
|
||||
|
||||
function ListTest() {
|
||||
// List data
|
||||
const list = [
|
||||
{name: 'Brian Vaughn', occupation: 'Software Engineer', location: 'San Jose, CA, 95125' /* ... */}
|
||||
// And so on...
|
||||
];
|
||||
|
||||
// Render your List
|
||||
ReactDOM.render(
|
||||
<List
|
||||
width={300}
|
||||
height={300}
|
||||
rowHeight={30}
|
||||
rowCount={list.length}
|
||||
rowRenderer={({ index, isScrolling }) => list[index]}
|
||||
/>,
|
||||
document.getElementById('example')
|
||||
);
|
||||
}
|
||||
|
||||
function VirtualScrollTest() {
|
||||
// List data as an array of strings
|
||||
const list = [
|
||||
|
||||
Reference in New Issue
Block a user