Skip to content

Commit c318ca2

Browse files
authored
fix(Charts): fix crash in ComposedChart on click when onDataPointClick is not set (#483)
1 parent cb8c0ec commit c318ca2

File tree

1 file changed

+3
-3
lines changed
  • packages/charts/src/components/ComposedChart

1 file changed

+3
-3
lines changed

packages/charts/src/components/ComposedChart/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ const ComposedChart: FC<ComposedChartProps> = forwardRef((props: ComposedChartPr
159159

160160
const onDataPointClickInternal = useCallback(
161161
(payload, eventOrIndex, event) => {
162-
if (payload.name && onDataPointClick) {
163-
onDataPointClick(
162+
if (payload.name) {
163+
typeof onDataPointClick === 'function' && onDataPointClick(
164164
enrichEventWithDetails(event ?? eventOrIndex, {
165165
value: payload.value.length ? payload.value[1] - payload.value[0] : payload.value,
166166
dataIndex: payload.index ?? eventOrIndex,
@@ -176,7 +176,7 @@ const ComposedChart: FC<ComposedChartProps> = forwardRef((props: ComposedChartPr
176176
})
177177
);
178178
} else {
179-
onDataPointClick(
179+
typeof onDataPointClick === 'function' && onDataPointClick(
180180
enrichEventWithDetails(
181181
{},
182182
{

0 commit comments

Comments
 (0)