Skip to content

Commit af640d3

Browse files
(updated) TS type for props
1 parent 7c37975 commit af640d3

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

src/app/components/PerformanceVisx.tsx

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ This side effect is only seen in recoil apps...
2020
*/
2121

2222
/* TYPESCRIPT */
23+
type margin = { top: number; right: number; bottom: number; left: number };
2324
type snapshot = any;
24-
2525
type TooltipData = {
2626
bar: SeriesPoint<snapshot>;
2727
key: CityName;
@@ -37,16 +37,14 @@ type TooltipData = {
3737
type BarStackProps = {
3838
width: number;
3939
height: number;
40-
margin?: { top: number; right: number; bottom: number; left: number };
41-
events?: boolean;
42-
snapshots?: any;
43-
hierarchy?: any;
40+
snapshots: [];
41+
hierarchy: any;
4442
};
4543

44+
45+
4646
/* DEFAULTS */
47-
const defaultMargin = {
48-
top: 60, right: 30, bottom: 0, left: 50,
49-
};
47+
const margin = { top: 60, right: 30, bottom: 0, left: 50 };
5048
const axisColor = '#679DCA';
5149
const background = '#242529';
5250
const tooltipStyles = {
@@ -92,14 +90,11 @@ const getSnapshotIds = (obj, snapshotIds = []) => {
9290
};
9391

9492
/* EXPORT COMPONENT */
95-
export default function PerformanceVisx({
96-
width,
97-
height,
98-
events = false,
99-
margin = defaultMargin,
100-
snapshots,
101-
hierarchy,
102-
}: BarStackProps) {
93+
94+
const PerformanceVisx = (props: BarStackProps) => {
95+
96+
const { width, height, snapshots, hierarchy } = props;
97+
10398
const {
10499
tooltipOpen,
105100
tooltipLeft,
@@ -118,6 +113,10 @@ export default function PerformanceVisx({
118113
const keys = Object.keys(data[0]).filter(d => d !== 'snapshotId') as CityName[];
119114
const allComponentStates = traverse(snapshots[0]);
120115

116+
console.log(snapshots);
117+
console.log(hierarchy);
118+
console.log('margin', margin);
119+
121120
// create array of total render times for each snapshot
122121
const totalRenderArr = data.reduce((totalRender, curSnapshot) => {
123122
const curRenderTotal = keys.reduce((acc, cur) => {
@@ -156,8 +155,8 @@ export default function PerformanceVisx({
156155
snapshotIdScale.rangeRound([0, xMax]);
157156
renderingScale.range([yMax, 0]);
158157

158+
// if performance tab is too small it will not return VISX component
159159
return width < 10 ? null : (
160-
// relative position is needed for correct tooltip positioning
161160

162161
<div style={{ position: 'relative' }}>
163162
<svg ref={containerRef} width={width} height={height}>
@@ -277,4 +276,6 @@ export default function PerformanceVisx({
277276
)}
278277
</div>
279278
);
280-
}
279+
};
280+
281+
export default PerformanceVisx;

0 commit comments

Comments
 (0)