I am customizing react big calendar toolbar, and it's working fine for switching month, but the issue is i am unable to switch week and days according to the current views. In every views next , prev button change the month. This is custom toolbar for navigating
const CustomToolbar = (toolbar, open, setOpen) => {
const goToBack = () => {
toolbar.date.setMonth(toolbar.date.getMonth() - 1);
toolbar.onNavigate("prev");
};
const goToNext = () => {
toolbar.onNavigate("next");
toolbar.date.setDays(toolbar.date.getDay() + 1);
//i want to change the dates state according to current view
};
const goToWeekView = () => {
toolbar.onView("week");
};
const goToMonthView = () => {
toolbar.onView("month");
};
const goToDayView = () => {
toolbar.onView("day");
};
const goToAgendaView = () => {
toolbar.onView("agenda");
};
return (
<Stack>
<Box className="back-next-buttons">
<Stack direction="row" alignItems="center">
<IconButton onClick={goToBack} className="btn-back">
<ArrowBackIosIcon />
</IconButton>
<Typography
onClick={goToCurrent} >
Today
</Typography>
<IconButton onClick={goToNext} className="btn-back">
<ArrowForwardIosIcon/>
</IconButton>
</Stack>
</Box>
{/* date label */}
<Typography>
{label()}
</Typography>
{/* view buttons */}
<Stack direction="row" flexWrap="wrap" alignItems="center">
<SmallButton
onClick={goToWeekView}
label="Week"/>
<SmallButton
onClick={goToMonthView}
label="Month"/>
<SmallButton
onClick={goToDayView}
label="Day"/>
<SmallButton
onClick={goToAgendaView}
label="All Events"/>
</Stack>
</Stack>
);
};