From 4c5a6bfdf12167cbe6a6f0dc6e180e4eb1f883dd Mon Sep 17 00:00:00 2001 From: Viktor Bersch Date: Wed, 6 May 2020 11:37:31 +0200 Subject: [PATCH] fix(Charts): fix crash in ComposedChart on click when onDataPointClick is not set --- packages/charts/src/components/ComposedChart/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/charts/src/components/ComposedChart/index.tsx b/packages/charts/src/components/ComposedChart/index.tsx index 842d1054505..af236c0814c 100644 --- a/packages/charts/src/components/ComposedChart/index.tsx +++ b/packages/charts/src/components/ComposedChart/index.tsx @@ -159,8 +159,8 @@ const ComposedChart: FC = forwardRef((props: ComposedChartPr const onDataPointClickInternal = useCallback( (payload, eventOrIndex, event) => { - if (payload.name && onDataPointClick) { - onDataPointClick( + if (payload.name) { + typeof onDataPointClick === 'function' && onDataPointClick( enrichEventWithDetails(event ?? eventOrIndex, { value: payload.value.length ? payload.value[1] - payload.value[0] : payload.value, dataIndex: payload.index ?? eventOrIndex, @@ -176,7 +176,7 @@ const ComposedChart: FC = forwardRef((props: ComposedChartPr }) ); } else { - onDataPointClick( + typeof onDataPointClick === 'function' && onDataPointClick( enrichEventWithDetails( {}, {