Skip to content

Commit 975f0cc

Browse files
committed
started adding useState to StateRoute for no render data
1 parent 1b0180d commit 975f0cc

File tree

3 files changed

+26
-42
lines changed

3 files changed

+26
-42
lines changed

src/app/components/PerfView.tsx

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
/* eslint-disable no-plusplus */
77
/* eslint-disable func-names */
88
/* eslint-disable no-shadow */
9-
/* eslint-disable no-multi-spaces */
109
/* eslint-disable newline-per-chained-call */
1110
/* eslint-disable object-curly-newline */
1211
/* eslint-disable object-property-newline */
1312
/* eslint-disable class-methods-use-this */
1413
// eslint-disable-next-line object-curly-newline
15-
/* eslint-disable comma-dangle */
1614
/* eslint-disable indent */
1715
/* eslint-disable no-console */
1816

@@ -23,15 +21,16 @@ import { schemeSet1 as colorScheme } from 'd3';
2321
// import { addNewSnapshots } from '../actions/actions.ts';
2422

2523
interface PerfViewProps {
26-
snapshots:any[];
27-
viewIndex:number;
24+
snapshots:any[];
25+
viewIndex:number;
2826
width: number;
2927
height: number;
28+
setNoRenderData: any;
3029
}
3130

3231
const PerfView = (props:PerfViewProps) => {
33-
const { snapshots, viewIndex, width, height } = props
34-
let adjustedSize = Math.min(width, height);
32+
const { snapshots, viewIndex, width, height, setNoRenderData } = props;
33+
const adjustedSize = Math.min(width, height);
3534
const svgRef = useRef(null);
3635

3736
// Figure out which snapshot index to use
@@ -42,7 +41,7 @@ const PerfView = (props:PerfViewProps) => {
4241
// Set up color scaling function
4342
const colorScale = d3.scaleLinear()
4443
.domain([0, 7])
45-
.range(['hsl(200,60%,60%)', 'hsl(255,30%,60%)'])
44+
.range(['hsl(200,60%,60%)', 'hsl(255,30%,40%)'])
4645
.interpolate(d3.interpolateHcl);
4746

4847
// Set up circle-packing layout function
@@ -55,6 +54,10 @@ const PerfView = (props:PerfViewProps) => {
5554
.sort((a:{value:number}, b:{value:number}) => { return b.value - a.value; }));
5655
}, [adjustedSize]);
5756

57+
function onNoRenderData() {
58+
setNoRenderData(false);
59+
}
60+
5861
// If indexToDisplay changes, clear old tree nodes
5962
useEffect(() => {
6063
while (svgRef.current.hasChildNodes()) {
@@ -78,11 +81,7 @@ const PerfView = (props:PerfViewProps) => {
7881
// View [x, y, r]
7982
let view;
8083

81-
// Set up viewBox dimensions and onClick for parent svg
82-
83-
// console.log("PerfView -> height", height)
84-
// console.log("PerfView -> width", width)
85-
// console.log("PerfView -> adjustedSize", adjustedSize)
84+
// Set up viewBox dimensions and onClick for parent svg
8685
const svg = d3.select(svgRef.current)
8786
.attr('viewBox', `-${adjustedSize / 2} -${adjustedSize / 2} ${width} ${height}`)
8887
.on('click', () => zoomToNode(packedRoot));
@@ -154,8 +153,4 @@ const PerfView = (props:PerfViewProps) => {
154153
);
155154
};
156155

157-
export default PerfView;
158-
159-
160-
// d3.quantize(d3.interpolateHcl('#60c96e', '#4d4193'), 10);
161-
// const colorScale = d3.scaleOrdinal(colorScheme);
156+
export default PerfView;

src/app/components/StateRoute.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
/* eslint-disable max-len */
22
/* eslint-disable object-curly-newline */
3-
import React from 'react';
3+
import React, { useState } from 'react';
44
import { MemoryRouter as Router, Route, NavLink, Switch } from 'react-router-dom';
5-
6-
7-
const Chart = require('./Chart').default;
85
import Tree from './Tree';
96
import PerfView from './PerfView';
7+
8+
const Chart = require('./Chart').default;
109
const ErrorHandler = require('./ErrorHandler').default;
1110

1211
const NO_STATE_MSG = 'No state change detected. Trigger an event to change state';
1312
// eslint-disable-next-line react/prop-types
1413

15-
1614
interface StateRouteProps {
17-
snapshot: { name?: string; componentData?: object; state?: string | object; stateSnaphot?: object; children?: any[]; };
18-
hierarchy: object;
19-
snapshots: [];
15+
snapshot: { name?: string; componentData?: object; state?: string | object; stateSnaphot?: object; children?: any[]; };
16+
hierarchy: object;
17+
snapshots: [];
2018
viewIndex: number;
2119
}
2220

2321
const StateRoute = (props:StateRouteProps) => {
24-
const { snapshot, hierarchy, snapshots, viewIndex } = props
22+
const { snapshot, hierarchy, snapshots, viewIndex } = props;
23+
const [noRenderData, setNoRenderData] = useState(true);
24+
2525
// gabi :: the hierarchy get set on the first click in the page, when page in refreshed we don't have a hierarchy so we need to check if hierarchy was initialize involk render chart
2626
const renderChart = () => {
2727
if (hierarchy) {
@@ -42,7 +42,7 @@ const StateRoute = (props:StateRouteProps) => {
4242
if (hierarchy) {
4343
return (
4444
<ErrorHandler>
45-
<PerfView viewIndex={viewIndex} snapshots={snapshots} width={600} height={1000}/>
45+
<PerfView viewIndex={viewIndex} snapshots={snapshots} setNoRenderData={setNoRenderData} width={600} height={1000} />
4646
</ErrorHandler>
4747
);
4848
}
@@ -53,13 +53,13 @@ const StateRoute = (props:StateRouteProps) => {
5353
<Router>
5454
<div className="navbar">
5555
<NavLink className="router-link" activeClassName="is-active" exact to="/">
56-
Tree
56+
Tree
5757
</NavLink>
5858
<NavLink className="router-link" activeClassName="is-active" to="/chart">
59-
History
59+
History
6060
</NavLink>
6161
<NavLink className="router-link" activeClassName="is-active" to="/performance">
62-
Performance
62+
Performance
6363
</NavLink>
6464
</div>
6565
<Switch>
@@ -71,4 +71,4 @@ const StateRoute = (props:StateRouteProps) => {
7171
);
7272
};
7373

74-
export default StateRoute;
74+
export default StateRoute;

src/backend/linkFiber.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,6 @@ export default (snap: Snapshot, mode: Mode): ()=>void => {
111111
treeBaseDuration,
112112
} = currentFiber;
113113

114-
<<<<<<< HEAD
115-
let newState: any = {};
116-
let componentData: ComponentData = {};
117-
=======
118114
let newState: any;
119115
let componentData: ComponentData = {};
120116
/* = {
@@ -125,7 +121,6 @@ export default (snap: Snapshot, mode: Mode): ()=>void => {
125121
treeBaseDuration: 0,
126122
};
127123
*/
128-
>>>>>>> master
129124
let componentFound = false;
130125

131126
// Check if node is a stateful setState component
@@ -182,10 +177,7 @@ export default (snap: Snapshot, mode: Mode): ()=>void => {
182177

183178
let newNode = null;
184179
// We want to add this fiber node to the snapshot
185-
<<<<<<< HEAD
186-
=======
187180
// const snapshotState = newState.state || newState.hooksState;
188-
>>>>>>> master
189181
if (componentFound || newState === 'stateless') {
190182
if (fromSibling) {
191183
newNode = tree.addSibling(newState,
@@ -229,10 +221,7 @@ export default (snap: Snapshot, mode: Mode): ()=>void => {
229221

230222
function onVisibilityChange(): void {
231223
doWork = !document.hidden;
232-
<<<<<<< HEAD
233-
=======
234224
// console.log('doWork is:', doWork);
235-
>>>>>>> master
236225
}
237226

238227
return () => {

0 commit comments

Comments
 (0)