I'm currently working on a pie chart for which I want to change the layout depending on the size of the window (namely change the position of the legend from left to bottom).
function PieChart() {
const { width } = useWindowSize();
return (
<React.Fragment>
<Pie
data={data}
width={width < size.smallDevices ? 100 : "auto"}
legend={width < size.smallDevices ? legendOptsSmall : legendOptsLarge}
/>
<div>{width < size.smallDevices ? "Small devices" : "Big devices"}</div>
</React.Fragment>
);
}
In this example, where width returns the width of the window, the div correctly changes from "Small devices" to "Big devices" while I resize the window, but the Pie from react-chartjs-2 doesn't change. However, when refreshed, the Pie correctly loads with the right layout (for small devices or big devices, depending on the situation). Only the hot refresh is failing.
Any idea on how to get a hot refresh?
Thanks!