From 8e3c1de79a939f5fa39124ae31011a403c6462c7 Mon Sep 17 00:00:00 2001 From: Timmy Luong Date: Thu, 29 Apr 2021 10:10:17 -0700 Subject: [PATCH] fix: add optional chaining to protect against null from getSpec (#563) --- giraffe/src/components/SizedPlot.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/giraffe/src/components/SizedPlot.tsx b/giraffe/src/components/SizedPlot.tsx index bace0465..0e3bec5f 100644 --- a/giraffe/src/components/SizedPlot.tsx +++ b/giraffe/src/components/SizedPlot.tsx @@ -93,9 +93,11 @@ export const SizedPlot: FunctionComponent = ({ const valueX = env.xScale.invert(hoverEvent.x) let clampedValueX = NaN + if ( valueX && - (defaultSpec.type === SpecTypes.Band || defaultSpec.type === SpecTypes.Line) + (defaultSpec?.type === SpecTypes.Band || + defaultSpec?.type === SpecTypes.Line) ) { const timestamps = defaultSpec?.lineData[0]?.xs ?? [] clampedValueX = nearestTimestamp(timestamps, valueX)