Skip to content

Commit e36c1fc

Browse files
authored
Merge pull request #10 from lu0713/master
optimize rendering
2 parents 2fd9353 + 22e3665 commit e36c1fc

31 files changed

+176
-100
lines changed

app/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
22
import Splash from './components/Splash';
33
import DashboardContainer from './containers/DashboardContainer';
44

5-
const App: React.FC = () => {
5+
const App: React.FC = React.memo(() => {
66
// Disable splash for development
77
// const [firstVisit, setFirstVisit] = useState(false);
88

@@ -11,6 +11,6 @@ const App: React.FC = () => {
1111

1212
// Splash image on startup
1313
return firstVisit ? <Splash setFirstVisit={setFirstVisit} /> : <DashboardContainer />;
14-
};
14+
});
1515

1616
export default App;

app/charts/DockerChart.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ interface IContainer {
2222
* Table that displays real-time Docker container information using the
2323
* latest data point available ???
2424
*/
25-
const DockerStatsChart = () => {
25+
const DockerStatsChart = React.memo(() => {
2626
const { dockerData } = useContext(DockerContext);
2727

2828
const {
@@ -57,6 +57,6 @@ const DockerStatsChart = () => {
5757
<span>Restart Count: {restartcount}</span>
5858
</div>
5959
) : null;
60-
};
60+
});
6161

6262
export default DockerStatsChart;

app/charts/LatencyChart.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useContext } from 'react';
22
import Plot from 'react-plotly.js';
33
import { HealthContext } from '../context/HealthContext';
44

5-
const LatencyChart = () => {
5+
const LatencyChart = React.memo(() => {
66
const { healthData } = useContext(HealthContext);
77

88
const createChart = () => {
@@ -57,6 +57,6 @@ const LatencyChart = () => {
5757
};
5858

5959
return <div className="chart">{createChart()}</div>;
60-
};
60+
});
6161

6262
export default LatencyChart;

app/charts/MemoryChart.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useContext } from 'react';
22
import Plot from 'react-plotly.js';
33
import { HealthContext } from '../context/HealthContext';
44

5-
const MemoryChart = () => {
5+
const MemoryChart = React.memo(() => {
66
const { healthData } = useContext(HealthContext);
77
const createChart = () => {
88
const free: number[] = healthData.freememory;
@@ -67,6 +67,6 @@ const MemoryChart = () => {
6767
};
6868

6969
return <div className="chart">{createChart()}</div>;
70-
};
70+
});
7171

7272
export default MemoryChart;

app/charts/ProcessesChart.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useContext } from 'react';
22
import Plot from 'react-plotly.js';
33
import { HealthContext } from '../context/HealthContext';
44

5-
const ProcessesChart = () => {
5+
const ProcessesChart = React.memo(() => {
66
const { healthData } = useContext(HealthContext);
77
const createChart = () => {
88
const runningProcesses: Array<number> = healthData.runningprocesses;
@@ -71,6 +71,6 @@ const ProcessesChart = () => {
7171
};
7272

7373
return <div className="chart">{createChart()}</div>;
74-
};
74+
});
7575

7676
export default ProcessesChart;

app/charts/RequestTypesChart.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useContext } from 'react';
22
import Plot from 'react-plotly.js';
33
import { CommsContext } from '../context/CommsContext';
44

5-
const RequestTypesChart: React.FC = () => {
5+
const RequestTypesChart: React.FC = React.memo(() => {
66
const { commsData } = useContext(CommsContext);
77

88
interface IObject {
@@ -78,6 +78,6 @@ const RequestTypesChart: React.FC = () => {
7878
};
7979

8080
return <div className="chart">{createRequestChart()}</div>;
81-
};
81+
});
8282

8383
export default RequestTypesChart;

app/charts/ResponseCodesChart.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface IObj {
1313
time: string;
1414
}
1515

16-
const ResponseCodesChart: React.FC = () => {
16+
const ResponseCodesChart: React.FC = React.memo(() => {
1717
const { commsData } = useContext(CommsContext);
1818

1919
const createChart = () => {
@@ -94,6 +94,6 @@ const ResponseCodesChart: React.FC = () => {
9494
};
9595

9696
return <div className="chart">{createChart()}</div>;
97-
};
97+
});
9898

9999
export default ResponseCodesChart;

app/charts/RouteChart.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { CommsContext } from '../context/CommsContext';
66
// import { log } from 'console';
77
import Graph from 'react-graph-vis';
88

9-
const RouteLocations = props => {
9+
const RouteLocations = React.memo(() => {
1010
const communicationsData = useContext(CommsContext).commsData;
1111
console.log('commdata=======>', communicationsData);
1212
console.log('try again');
@@ -136,7 +136,6 @@ const RouteLocations = props => {
136136
const options = {
137137
height: '300px',
138138
width: '300px',
139-
style: 'surface',
140139
layout: {
141140
hierarchical: false
142141
},
@@ -168,6 +167,6 @@ const RouteLocations = props => {
168167
<Graph className={classes.paper} graph={graph} options={options} events={events} style={{ fontSize: '2px', color: '#555555', fontFamily: 'Open Sans', boxShadow: '3px 3px 6px 1px rgb(175, 175, 175)', backgroundColor: 'white', borderRadius: '3px' }} />
169168
</div>
170169
);
171-
};
170+
});
172171

173172
export default RouteLocations;

app/charts/SpeedChart.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Plot from 'react-plotly.js';
33
import { HealthContext } from '../context/HealthContext';
44
import moment from 'moment';
55

6-
const SpeedChart = () => {
6+
const SpeedChart = React.memo(() => {
77
const { healthData } = useContext(HealthContext);
88
const { time, cpuspeed } = healthData;
99
const yAxis = cpuspeed;
@@ -64,6 +64,6 @@ const SpeedChart = () => {
6464
};
6565

6666
return <div className="chart">{createChart()}</div>;
67-
};
67+
});
6868

6969
export default SpeedChart;

app/charts/TemperatureChart.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Plot from 'react-plotly.js';
33
import moment from 'moment';
44
import { HealthContext } from '../context/HealthContext';
55

6-
const TemperatureChart = () => {
6+
const TemperatureChart = React.memo(() => {
77
const { healthData } = useContext(HealthContext);
88
const { time, cputemp } = healthData;
99

@@ -69,6 +69,6 @@ const TemperatureChart = () => {
6969
};
7070

7171
return <div className="chart">{createChart()}</div>;
72-
};
72+
});
7373

7474
export default TemperatureChart;

0 commit comments

Comments
 (0)