Refactor Calendar component to update month details only when year or month changes

This commit is contained in:
Sergey Krashevich 2023-08-03 10:04:05 +03:00
parent 98576418a8
commit 0a1024983d
No known key found for this signature in database
GPG Key ID: 625171324E7D3856

View File

@ -101,10 +101,9 @@ const Calendar = ({ onChange, calendarRef, close, dateRange, children }) => {
setState((prev) => ({ setState((prev) => ({
...prev, ...prev,
selectedDay: todayTimestamp, selectedDay: todayTimestamp,
monthDetails: getMonthDetails(year, month), monthDetails: getMonthDetails(year, month)
timeRange: { ...dateRange },
})); }));
}, [year, month, getMonthDetails, dateRange]); }, [year, month, getMonthDetails]);
useEffect(() => { useEffect(() => {
// add refs for keyboard navigation // add refs for keyboard navigation