You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to report that a small logic error stops SSR from working for XYchart.
In useScales line 43, x/yScale will be returned as undefined if there are no values in the dataRegistry. This stops render of all children of XYChart (Axis, Grid, etc.).
In withRegisteredData line 56, the Series component will not be rendered if there is no x/yScale. This is done on line 48 in a useEffect block. I would propose moving the initial registerData call out of useEffect.
The text was updated successfully, but these errors were encountered:
Yes, the implementation of the data registry (whereby child components register their data in the parent chart context) with useEffect does prevent XYChart from being server-side rendered.
would propose moving the initial registerData call out of useEffect
There is no hook that is analogous to the legacy class component method componentWillMount. we could consider adding something a custom hook like the following as a workaround:
Thanks for quick response! Loving visx so far, especially XYChart. The reason I wanted it was because I wanted SVG for SSR charts, so I moved away from . My non-XYcharts work very well.
Hmm maybe that idea could work.. The DataProvider scales are only known after the render… would that imply using useComponentWillMount everywhere?
The other idea (might be a breaking change), would be to define all data upfront in the DataProvider, and have each Series component link into the dataRegistry via DataKey. This could be opt-in behaviour?
Hello,
I wanted to report that a small logic error stops SSR from working for XYchart.
In useScales line 43, x/yScale will be returned as undefined if there are no values in the dataRegistry. This stops render of all children of XYChart (Axis, Grid, etc.).
In withRegisteredData line 56, the Series component will not be rendered if there is no x/yScale. This is done on line 48 in a
useEffect
block. I would propose moving the initialregisterData
call out ofuseEffect
.The text was updated successfully, but these errors were encountered: