-
Notifications
You must be signed in to change notification settings - Fork 200
/
Copy pathtypes.d.ts
83 lines (68 loc) · 2.01 KB
/
types.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import * as React from 'react';
export interface HookDifference {
pathString: string;
diffType: string;
prevValue: any;
nextValue: any;
}
export interface ReasonForUpdate {
hookDifferences: HookDifference[];
propsDifferences: boolean;
stateDifferences: boolean;
}
export interface UpdateInfo {
Component: React.Component;
displayName: string;
prevProps: any;
prevState: any;
nextProps: any;
nextState: any;
prevHook: any;
nextHook: any;
reason: ReasonForUpdate;
options: WhyDidYouRenderOptions;
hookName?: string;
}
export type ExtraHookToTrack = [any, string];
export interface WhyDidYouRenderOptions {
include?: RegExp[];
exclude?: RegExp[];
trackAllPureComponents?: boolean;
trackHooks?: boolean;
logOwnerReasons?: boolean;
trackExtraHooks?: Array<ExtraHookToTrack>;
logOnDifferentValues?: boolean;
hotReloadBufferMs?: number;
onlyLogs?: boolean;
collapseGroups?: boolean;
titleColor?: string;
diffNameColor?: string;
diffPathColor?: string;
notifier?: Notifier;
}
export type WhyDidYouRenderComponentMember = WhyDidYouRenderOptions|boolean
export type Notifier = (options: UpdateInfo) => void
declare function whyDidYouRender(react: typeof React, options?: WhyDidYouRenderOptions): typeof React;
declare namespace whyDidYouRender {
export const defaultNotifier: Notifier;
}
export default whyDidYouRender;
declare module 'react' {
interface FunctionComponent<P = {}> {
whyDidYouRender?: WhyDidYouRenderComponentMember;
}
interface ExoticComponent<P = {}> {
whyDidYouRender?: WhyDidYouRenderComponentMember;
}
namespace Component {
const whyDidYouRender: WhyDidYouRenderComponentMember;
}
/* not supported.
see https://github.com/microsoft/TypeScript/issues/33892
and https://github.com/microsoft/TypeScript/issues/34516
and https://github.com/microsoft/TypeScript/issues/32185
// interface Component<P = {}, S = {}, SS = any> extends ComponentLifecycle<P, S, SS> {
// static whyDidYouRender?: WhyDidYouRenderComponentMember;
// }
*/
}