Description
Hello! Loving this library, found it very easy to make nice things :)
I found what I think is a bug in the handling of the values passed to the series
attribute of the options
prop in the HighchartsReact
component.
I have a component like this. I've omitted quite few of the options
for conciseness:
import React from "react";
import Highcharts from "highcharts";
import HighchartsReact from "highcharts-react-official";
export default function Chart({
testStoreData,
controlStoreData,
}) {
return (
<HighchartsReact
highcharts={Highcharts}
options={{
series: [
{
name: "Test",
data: testStoreData,
},
{
name: "Control",
data: controlStoreData,
},
],
}}
/>
);
}
This component is being rendered by another component which conditionally passes different values for testStoreData
and controlStoreData
. The different values are stored in state.
What's happening is that, when the values for testStoreData
and controlStoreData
change, the values of the upstream state are being changed. Took me quite a while to figure out what was happening.
Workaround
If you replace this:
series: [
{
name: "Test",
data: testStoreData,
},
{
name: "Control",
data: controlStoreData,
},
],
with
series: [
{
name: "Test",
data: [...testStoreData],
},
{
name: "Control",
data: [...controlStoreData],
},
],
the problem goes away. It's not ideal, especially if you had a very large data set (mine isn't huge atm), but it works.
I haven't had a chance to look at the source code for this project to isolate where this is happening.
Hope this is helpful. Let me know if you have any questions for me.