The problem I'm having is whenever the data that is passed into the jvectormap changes, the map doesn't reflect the changes.
Inside my state, I have two sets of data: data1 and data2. Inside my render method, I have a button where once clicked, it'll change this.state.data1 to have the same contents as this.state.data2 since the map takes this.state.data1 as the value for markers. Here is my render function:
render() {
return (
<div>
<a
href="#"
onClick={() =>
this.setState({ data1: this.state.data2 }, () =>
console.log(this.state.data1)
)
}
>
Click
</a>
<div style={{ width: 500, height: 300 }}>
<VectorMap
map={"world_mill"}
backgroundColor="#FFFFF"
markerStyle={{
initial: {
fill: "#FFFF",
stroke: "#383f47"
}
}}
series={{
markers: [
{
attribute: "r",
scale: [5, 20],
values: [60, 6, 54],
normalizeFunction: "polynomial"
}
]
}}
regionStyle={{
initial: {
fill: "#128da7"
},
hover: {
fill: "#A0D1DC"
}
}}
markers={this.state.data1}
ref="map"
containerStyle={{
width: "100%",
height: "100%"
}}
containerClassName="map"
/>
</div>
</div>
);
}
}
The whole code is simple and can be found here: https://codesandbox.io/s/2vx2k1vl9n.
As you can see, in the onClick method for the button, I print data1 after setting the state in order to make sure that its value changes which it does, but it's not being reflected on the map. Can anyone help me with this?
Thanks in advance!