Skip to content

Commit

Permalink
fix: add optional chaining to protect against null from getSpec (#563)
Browse files Browse the repository at this point in the history
  • Loading branch information
TCL735 authored Apr 29, 2021
1 parent 9971a26 commit 8e3c1de
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion giraffe/src/components/SizedPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ export const SizedPlot: FunctionComponent<SizedPlotProps> = ({

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)
Expand Down

0 comments on commit 8e3c1de

Please sign in to comment.