Skip to content

Commit 1e67a48

Browse files
authored
Merge pull request #34 from Weffe/type-definitions
Add type definitions for registerObserver
2 parents 438d4f9 + 2a8ba4d commit 1e67a48

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

index.d.ts

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
interface IOptions {
2+
shouldLog?: boolean;
3+
port?: number;
4+
components?: string[];
5+
}
6+
7+
interface IMeasureDetail {
8+
averageTimeSpentMs: string;
9+
numberOfTimes: number;
10+
totalTimeSpentMs: number;
11+
}
12+
13+
interface IMeasure {
14+
componentName: string; // Name of the component
15+
totalTimeSpent: number; // Total time taken by the component combining all the phases
16+
percentTimeSpent: string; // Percent time
17+
numberOfInstances: number; // Number of instances of the component
18+
mount: IMeasureDetail; // Mount time
19+
render: IMeasureDetail; // Render time
20+
update: IMeasureDetail; // Update time
21+
unmount: IMeasureDetail; // Unmount time
22+
23+
// Time taken in lifecycle hooks
24+
componentWillMount: IMeasureDetail;
25+
componentDidMount: IMeasureDetail;
26+
componentWillReceiveProps: IMeasureDetail;
27+
shouldComponentUpdate: IMeasureDetail;
28+
componentWillUpdate: IMeasureDetail;
29+
componentDidUpdate: IMeasureDetail;
30+
componentWillUnmount: IMeasureDetail;
31+
}
32+
33+
declare module 'react-perf-devtool' {
34+
function registerObserver(
35+
options?: IOptions,
36+
callback?: (measures: Array<IMeasure>) => void
37+
): void
38+
}

0 commit comments

Comments
 (0)