From 8c77ad59d074a600fee0a44aa79892cea7c57d48 Mon Sep 17 00:00:00 2001 From: Kaio de Almeida Santos <87026158+kaiodealmeida@users.noreply.github.com> Date: Fri, 12 May 2023 10:24:10 -0300 Subject: [PATCH] fix(DatePicker): onChange callback not being called (#13774) * fix: onChange callback not being called add undefined as useSavedCallback param type and remove arrow func param * fix(DatePicker): fix code format with prettier --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- packages/react/src/components/DatePicker/DatePicker.tsx | 3 +-- packages/react/src/internal/useSavedCallback.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/react/src/components/DatePicker/DatePicker.tsx b/packages/react/src/components/DatePicker/DatePicker.tsx index 37b1e5a189b7..92f6047d22f6 100644 --- a/packages/react/src/components/DatePicker/DatePicker.tsx +++ b/packages/react/src/components/DatePicker/DatePicker.tsx @@ -462,10 +462,9 @@ const DatePicker = React.forwardRef(function DatePicker( }); }; - //const savedOnOpen = useSavedCallback(onOpen); const endInputField = useRef(null); const calendarRef: any | undefined = useRef(null); - const savedOnChange = useSavedCallback(() => onChange); + const savedOnChange = useSavedCallback(onChange); const savedOnClose = useSavedCallback( datePickerType === 'range' ? onCalendarClose : onClose ); diff --git a/packages/react/src/internal/useSavedCallback.js b/packages/react/src/internal/useSavedCallback.js index 5eab87efa181..f7c1a37bf48b 100644 --- a/packages/react/src/internal/useSavedCallback.js +++ b/packages/react/src/internal/useSavedCallback.js @@ -13,7 +13,7 @@ import { useCallback, useEffect, useRef } from 'react'; * callback prop but don't want it to be added to the dependency array of an * effect. * - * @param {Function} callback + * @param {Function | undefined} callback * @returns {Function} */ export function useSavedCallback(callback) {