mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-30 18:43:21 +08:00
Merge pull request #16547 from Lapanti/master
Add type definitions for react-infinite-scroller
This commit is contained in:
61
types/react-infinite-scroller/index.d.ts
vendored
Normal file
61
types/react-infinite-scroller/index.d.ts
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
// Type definitions for react-infinite-scroller 1.0.12
|
||||
// Project: https://github.com/CassetteRocks/react-infinite-scroller
|
||||
// Definitions by: Lauri Lavanti <https://github.com/Lapanti>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
declare module 'react-infinite-scroller' {
|
||||
import * as React from 'react';
|
||||
|
||||
/**
|
||||
* <InfiniteScroll /> properties.
|
||||
*/
|
||||
interface InfiniteScrollProps extends React.HTMLProps<InfiniteScroll> {
|
||||
/**
|
||||
* Name of the element that the component should render as.
|
||||
* Defaults to 'div'.
|
||||
*/
|
||||
element?: string;
|
||||
/**
|
||||
* Whether there are more items to be loaded. Event listeners are removed if false.
|
||||
* Defaults to false.
|
||||
*/
|
||||
hasMore?: boolean;
|
||||
/**
|
||||
* Whether the component should load the first set of items.
|
||||
* Defaults to true.
|
||||
*/
|
||||
initialLoad?: boolean;
|
||||
/**
|
||||
* Whether new items should be loaded when user scrolls to the top of the scrollable area.
|
||||
* Default to false.
|
||||
*/
|
||||
isReverse?: boolean;
|
||||
/**
|
||||
* A callback for when more items are requested by the user.
|
||||
*/
|
||||
loadMore(): void;
|
||||
/**
|
||||
* The number of the first page to load, with the default of 0, the first page is 1.
|
||||
* Defaults to 0.
|
||||
*/
|
||||
pageStart?: number;
|
||||
/**
|
||||
* The distance in pixels before the end of the items that will trigger a call to loadMore.
|
||||
* Defaults to 250.
|
||||
*/
|
||||
threshold?: number;
|
||||
/**
|
||||
* Proxy to the useCapture option of the added event listeners.
|
||||
* Defaults to false.
|
||||
*/
|
||||
useCapture?: boolean;
|
||||
/**
|
||||
* Add scroll listeners to the window, or else, the component's parentNode.
|
||||
* Defaults to true.
|
||||
*/
|
||||
useWindow?: boolean;
|
||||
}
|
||||
|
||||
export default class InfiniteScroll extends React.Component<InfiniteScrollProps, any> { }
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import * as React from 'react';
|
||||
import InfiniteScroll from 'react-infinite-scroller';
|
||||
|
||||
class Test1 extends React.Component<{}, {}> {
|
||||
public render() {
|
||||
return (
|
||||
<InfiniteScroll
|
||||
loadMore={() => {}}
|
||||
>
|
||||
<div>Test 1</div>
|
||||
</InfiniteScroll>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Test2 extends React.Component<{}, {}> {
|
||||
public render() {
|
||||
return (
|
||||
<InfiniteScroll
|
||||
loadMore={() => {}}
|
||||
element='section'
|
||||
hasMore
|
||||
initialLoad={false}
|
||||
isReverse
|
||||
pageStart={2}
|
||||
threshold={500}
|
||||
useCapture
|
||||
useWindow={false}
|
||||
>
|
||||
<div>Test 1</div>
|
||||
</InfiniteScroll>
|
||||
);
|
||||
}
|
||||
}
|
||||
24
types/react-infinite-scroller/tsconfig.json
Normal file
24
types/react-infinite-scroller/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": false,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"jsx": "react",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-infinite-scroller-tests.tsx"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user