Merge pull request #1102 from chaotixkilla/fix-analytics-page-graphs-memo

Fix analytics page graphs memoizing
This commit is contained in:
Rafael Taranto 2022-02-18 17:47:09 +00:00 committed by GitHub
commit fee6f64ac6
3 changed files with 12 additions and 5 deletions

View file

@ -14,7 +14,7 @@ export default {
},
select: {
width: WIDTH,
zIndex: 2,
zIndex: 1,
'& label': {
extend: label1,
color: offColor,

View file

@ -21,7 +21,8 @@ const Graph = ({
timezone,
setSelectionCoords,
setSelectionData,
setSelectionDateInterval
setSelectionDateInterval,
selectedMachine
}) => {
const ref = useRef(null)
@ -428,5 +429,6 @@ export default memo(
Graph,
(prev, next) =>
R.equals(prev.period, next.period) &&
R.equals(prev.selectedDay, next.selectedDay)
R.equals(prev.selectedDay, next.selectedDay) &&
R.equals(prev.selectedMachine, next.selectedMachine)
)

View file

@ -11,7 +11,7 @@ import {
fontSecondary
} from 'src/styling/variables'
const Graph = ({ data, machines, currency }) => {
const Graph = ({ data, machines, currency, selectedMachine }) => {
const ref = useRef(null)
const AMOUNT_OF_MACHINES = 5
@ -304,4 +304,9 @@ const Graph = ({ data, machines, currency }) => {
return <svg ref={ref} />
}
export default memo(Graph, (prev, next) => R.equals(prev.period, next.period))
export default memo(
Graph,
(prev, next) =>
R.equals(prev.period, next.period) &&
R.equals(prev.selectedMachine, next.selectedMachine)
)