Add undefined fallback for valueMonth state
Added else clauses to set valueMonth to undefined when month values are not provided: - Prevents stale date values in calendar - Ensures calendar displays correctly when switching between date ranges 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -55,6 +55,8 @@ const NiceCalendarMonth = ({
|
|||||||
if (startDate.isValid()) {
|
if (startDate.isValid()) {
|
||||||
setValueMonth(startDate.toDate());
|
setValueMonth(startDate.toDate());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
setValueMonth(undefined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(calendarType === CalendarType.End){
|
else if(calendarType === CalendarType.End){
|
||||||
@@ -71,6 +73,8 @@ const NiceCalendarMonth = ({
|
|||||||
if (endDate.isValid()) {
|
if (endDate.isValid()) {
|
||||||
setValueMonth(endDate.toDate());
|
setValueMonth(endDate.toDate());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
setValueMonth(undefined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(calendarType === CalendarType.Single){
|
else if(calendarType === CalendarType.Single){
|
||||||
@@ -79,6 +83,8 @@ const NiceCalendarMonth = ({
|
|||||||
if (singleDate.isValid()) {
|
if (singleDate.isValid()) {
|
||||||
setValueMonth(singleDate.toDate());
|
setValueMonth(singleDate.toDate());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
setValueMonth(undefined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user