Skip to content

Commit 0b535af

Browse files
committed
chore: Add type definition
1 parent 82e1ccb commit 0b535af

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

src/index.d.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/// <reference types="react" />
2+
import { ReactType } from 'react';
3+
export declare type Properties = {
4+
/**
5+
* Property to look for, if prop.loading is true then the [spinnerComponent]
6+
* will get rendered.
7+
* Defaults to 'data'.
8+
*/
9+
prop?: string | Array<string>;
10+
/**
11+
* Timeout in milliseconds, the [spinnerComponent] wont get rendered
12+
* before the timeout.
13+
* Defaults to 100.
14+
*/
15+
timeout?: number;
16+
/**
17+
* If the HOC should handle errors, if true the [errorComponent] will be rendered.
18+
* Defaults to true.
19+
*/
20+
handleError?: boolean;
21+
/**
22+
* Component to be rendered if an error occurs.
23+
* Defaults to null.
24+
*/
25+
errorComponent?: ReactType;
26+
/**
27+
* If the HOC should take partial data into account.
28+
* Defaults to false.
29+
*/
30+
partial?: boolean;
31+
/**
32+
* Component that should be rendered while loading.
33+
* Defaults to a React Toolbox ProgressBar component.
34+
*/
35+
spinnerComponent?: ReactType;
36+
/**
37+
* Extra props that should be passed to the [spinnerComponent].
38+
*/
39+
spinnerProps?: Object;
40+
/**
41+
* Function that can be used to skip rendering the [errorComponent].
42+
* If it returns true the [errorComponent] will not get rendered.
43+
* This can for example be used to skip rendering the [errorComponent]
44+
* for validation errors.
45+
*/
46+
skipErrors?: (data: any) => boolean;
47+
emptyComponent?: ReactType;
48+
};
49+
export declare const withSpinner: ({prop, timeout, handleError, partial, skipErrors, spinnerProps, errorComponent: ErrorComponent, spinnerComponent: Spinner, emptyComponent: EmptyComponent}?: Properties) => any;

0 commit comments

Comments
 (0)