I'm using react-big-calendar to display events, I want to call a function to set state inside the onNavigate callback but doing this prevents navigation to the next month in the calendar view.
This is what I want to do which results to the calendar view not navigating
const [calendarStartDate, setCalendarStartDate] = useState(new Date());
<DraggableCalendar
localizer={localizer}
defaultView="month"
events={scheduledTestCases}
style={{ height: "80%", width: "95%" }}
views={{week: true, day: true, month: true}}
onNavigate={(newDate: Date, view: View)=>setCalendarStartDate(newDate)}
/>
currently I can do this inside the onNavigate callback and the navigation works fine
<DraggableCalendar
localizer={localizer}
defaultView="month"
events={scheduledTestCases}
style={{ height: "80%", width: "95%" }}
views={{week: true, day: true, month: true}}
onNavigate={(newDate: Date, view: View)=>console.log(newDate)}
/>
React-Big-Calendar has three variables that can be 'controlled' or 'uncontrolled'. When you provide
onView,onNavigateandonSelectEventmethods, RBC expects you to control the state ofview,dateandselectedyourself. By providing your ownonNavigatewithout a state controlleddateprop, it will call your method, but most of the internals will do nothing.