From 156d98c979c0624f854edc42e5a39c142afdbc60 Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Tue, 4 Oct 2022 09:54:43 +1100 Subject: [PATCH] Add comment about when width is not finite --- packages/components/src/components/DistributionChart.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/components/src/components/DistributionChart.tsx b/packages/components/src/components/DistributionChart.tsx index f89ee47e..e50afa0d 100644 --- a/packages/components/src/components/DistributionChart.tsx +++ b/packages/components/src/components/DistributionChart.tsx @@ -94,7 +94,9 @@ export const DistributionChart: React.FC = (props) => { maxY: Math.max(...domain.map((x) => x.y)), }); - let widthProp = width ? width : isFinite(size.width) ? size.width : 400; + // I think size.width is sometimes not finite due to the component not being in a visible context + // This occurs during testing + let widthProp = width ? width : Number.isFinite(size.width) ? size.width : 400; if (widthProp < 20) { console.warn( `Width of Distribution is set to ${widthProp}, which is too small`