I'm using FullCalander v5 for React, testing the Resource Timeline view. I'm encountering a problem with the "loading" function, the intent is to check the Fullcalendar state and in case of loading state true, display a Spinner type component (with a conditional render) instead of the Timeline, setting the Spinner component state to true with a useState. The problem is that, launching a useState from the Fullcalendar component, which is inside the render method, starts an infinite render loop. Any ideas to break the flow ?
// Loading function in the container component of Fullcalendar an the useState method
const [spinner, setSpinner] = useState(true);
let loadingFunction = (isLoading) => {
if (isLoading) {
console.log("loading");
setSpinner(true);
} else {
console.log("idle");
setSpinner(false);
}
};
// The conditional render
return (
<>
{spinner ? (
<Spinner />
) : (
<>
<FullCalendar
loading={loadingFunction}
ref={calendarRef}
dateClick={handleEventCreate}
.....