Skip to content

Commit fb1b33f

Browse files
committed
Add back timeZone useEffect
1 parent 0d1bd0e commit fb1b33f

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

packages/react-day-picker/src/useCalendar.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useMemo } from "react";
1+
import { useEffect, useMemo } from "react";
22

33
import type {
44
CalendarDay,
@@ -111,6 +111,18 @@ export function useCalendar(
111111
dateLib,
112112
);
113113

114+
// biome-ignore lint/correctness/useExhaustiveDependencies: change the initial month when the time zone changes.
115+
useEffect(() => {
116+
const newValidDisplayedFirstMonth = getValidDisplayedFirstMonth(
117+
props.month || props.defaultMonth || today,
118+
props.numberOfMonths || 1,
119+
navStart,
120+
navEnd,
121+
dateLib,
122+
);
123+
setFirstMonth(newValidDisplayedFirstMonth);
124+
}, [props.timeZone]);
125+
114126
/** The months displayed in the calendar. */
115127
// biome-ignore lint/correctness/useExhaustiveDependencies: We want to recompute only when specific props change.
116128
const { months, weeks, days, previousMonth, nextMonth } = useMemo(() => {

0 commit comments

Comments
 (0)