mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add type definitions for react-lazyload package. (#16807)
* Add type definitions for `react-lazyload` package. * fix lint error. * fix TypeScript Version
This commit is contained in:
parent
a6d85e88c1
commit
d82cb80219
26
types/react-lazyload/index.d.ts
vendored
Normal file
26
types/react-lazyload/index.d.ts
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
// Type definitions for react-lazyload ver 2.2
|
||||
// Project: https://github.com/jasonslyvia/react-lazyload
|
||||
// Definitions by: m0a <https://github.com/m0a>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
import {Component} from 'react';
|
||||
|
||||
export interface LazyLoadProps {
|
||||
once?: boolean;
|
||||
height?: number | string;
|
||||
offset?: number | string;
|
||||
overflow?: boolean;
|
||||
scroll?: boolean;
|
||||
children?: JSX.Element;
|
||||
throttle?: number | boolean;
|
||||
debounce?: number | boolean;
|
||||
placeholder?: Node;
|
||||
unmountIfInvisible?: boolean;
|
||||
}
|
||||
|
||||
export default class LazyLoad extends Component<LazyLoadProps, {}> {
|
||||
constructor(props: LazyLoad);
|
||||
}
|
||||
|
||||
export function lazyload(option: {}): LazyLoad;
|
||||
32
types/react-lazyload/react-lazyload-tests.tsx
Normal file
32
types/react-lazyload/react-lazyload-tests.tsx
Normal file
@ -0,0 +1,32 @@
|
||||
import * as React from "react";
|
||||
import LazyLoad from "react-lazyload";
|
||||
|
||||
interface State {
|
||||
arr: string[];
|
||||
}
|
||||
|
||||
class Normal extends React.Component<{}, State> {
|
||||
constructor() {
|
||||
super();
|
||||
let arr: string[] = [];
|
||||
for (let i = 0; i < 200; i++) {
|
||||
arr.push(`${i}`);
|
||||
}
|
||||
this.state = { arr };
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
{this.state.arr.map((el, index) => {
|
||||
return (
|
||||
<LazyLoad once={true} key={index} height={200} offset={50}>
|
||||
<p id={`${index}`} >
|
||||
count={index + 1}
|
||||
</p>
|
||||
</LazyLoad>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
24
types/react-lazyload/tsconfig.json
Normal file
24
types/react-lazyload/tsconfig.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "react"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-lazyload-tests.tsx"
|
||||
]
|
||||
}
|
||||
1
types/react-lazyload/tslint.json
Normal file
1
types/react-lazyload/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user