Fixed bug in populate days where day 2 was beimg skipped for each month.
This commit is contained in:
@@ -43,23 +43,19 @@ const CalenderContextProvider = ({
|
||||
getDate(endOfMonth(selectedDate))
|
||||
);
|
||||
|
||||
const [daysOfMonth, setDaysOfMonth] = useState<[number]>([0]);
|
||||
const [daysOfMonth, setDaysOfMonth] = useState<[number]>([1]);
|
||||
|
||||
// Update or populate the days of the month.
|
||||
const populateDays = (): void => {
|
||||
let newDaysOfMonth: [number] = [...daysOfMonth];
|
||||
|
||||
if (newDaysOfMonth.length > 1) {
|
||||
newDaysOfMonth = [0];
|
||||
newDaysOfMonth = [1];
|
||||
}
|
||||
|
||||
for (let i = 1; i < endOfSelectedMonth; i++) {
|
||||
if (newDaysOfMonth[i - 1] === 0) {
|
||||
newDaysOfMonth[i - 1] = i;
|
||||
} else {
|
||||
newDaysOfMonth.push(i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
setDaysOfMonth(newDaysOfMonth);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user