fix: analytics graph memoizing

This commit is contained in:
Sérgio Salgado 2022-02-10 18:09:39 +00:00
parent 4015e23d34
commit 35c81ce112
3 changed files with 12 additions and 5 deletions

View file

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

View file

@ -21,7 +21,8 @@ const Graph = ({
timezone, timezone,
setSelectionCoords, setSelectionCoords,
setSelectionData, setSelectionData,
setSelectionDateInterval setSelectionDateInterval,
selectedMachine
}) => { }) => {
const ref = useRef(null) const ref = useRef(null)
@ -428,5 +429,6 @@ export default memo(
Graph, Graph,
(prev, next) => (prev, next) =>
R.equals(prev.period, next.period) && 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 fontSecondary
} from 'src/styling/variables' } from 'src/styling/variables'
const Graph = ({ data, machines, currency }) => { const Graph = ({ data, machines, currency, selectedMachine }) => {
const ref = useRef(null) const ref = useRef(null)
const AMOUNT_OF_MACHINES = 5 const AMOUNT_OF_MACHINES = 5
@ -304,4 +304,9 @@ const Graph = ({ data, machines, currency }) => {
return <svg ref={ref} /> 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)
)