Skip to content

Commit

Permalink
performance: improve select in useRange (#2560)
Browse files Browse the repository at this point in the history
perf: proves loop in `useRange`
  • Loading branch information
gpbl authored Oct 27, 2024
1 parent 6ea775b commit 396f92e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/selection/useRange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ export function useRange<T extends DayPickerProps>(

if (newRange?.from && newRange.to) {
let newDate = newRange.from;
while (dateLib.differenceInCalendarDays(newRange.to, newDate) > 0) {
const totalDays = dateLib.differenceInCalendarDays(newRange.to, newDate);

for (let i = 0; i < totalDays; i++) {
newDate = dateLib.addDays(newDate, 1);

if (
excludeDisabled &&
disabled &&
Expand Down

0 comments on commit 396f92e

Please sign in to comment.