Skip to content

Commit

Permalink
fix(bump): Return a new serie reference when color or styles change
Browse files Browse the repository at this point in the history
This is the same fix as applied to area-bump in 412f0de
Contrary to area-bump, the previous implementation didn't lead to a visible bug, as whenever e.g. someone hovers over the graph, the memoization of the rendering component is broken by another object anyway, hence it doesn't matter that from a React's perspective the series objects are still the same.

Therefore this commit can be seen as a preemptive measure to avoid future problems.
  • Loading branch information
LFDM authored and plouc committed Dec 4, 2020
1 parent 844c311 commit 07c8ba1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/bump/src/bump/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ export const useBump = ({
const series = useMemo(
() =>
rawSeries.map(serie => {
serie.color = getColor(serie)
serie.style = getSerieStyle(serie)

return serie
const nextSerie = { ...serie }
nextSerie.color = getColor(nextSerie)
nextSerie.style = getSerieStyle(nextSerie)
return nextSerie
}),
[rawSeries, getColor, getSerieStyle]
)
Expand Down

0 comments on commit 07c8ba1

Please sign in to comment.