Reactjs FullCalendar最初为空

Reactjs FullCalendar最初为空,reactjs,fullcalendar,render,Reactjs,Fullcalendar,Render,我正在尝试在一个小项目中使用FullCalendar,我正在从后端加载我的事件。。。问题是日历最初显示为空,并且只有在我交换路由时才会显示事件(我单击另一个页面并返回到日历页面)。。如果我重新装弹,它们会再次消失。。我真的不明白原因 从“React”导入React 进口{ CCard, CCardBody, CCardHeader, C开关, CModal, CModalBody, 科莫达福特, CModalHeader, CMODataltle, 按钮控件 }来自“@coreui/reac

我正在尝试在一个小项目中使用FullCalendar,我正在从后端加载我的事件。。。问题是日历最初显示为空,并且只有在我交换路由时才会显示事件(我单击另一个页面并返回到日历页面)。。如果我重新装弹,它们会再次消失。。我真的不明白原因

从“React”导入React
进口{
CCard,
CCardBody,
CCardHeader,
C开关,
CModal,
CModalBody,
科莫达福特,
CModalHeader,
CMODataltle,
按钮控件
}来自“@coreui/react”
从“@FullCalendar/react”导入FullCalendar
//从“@fullcalendar/resource timeline”导入resourceTimelinePlugin
从“@fullcalendar/daygrid”导入dayGridPlugin
从“@fullcalendar/interaction”/”导入interactionPlugindayClick需要
从“/event utils”导入{INITIAL_EVENTS}
从“@fullcalendar/timegrid”导入timeGridPlugin
从“@fullcalendar/core/locales/fr”导入frLocale;
从“../../../services/auth.service”导入UserDataService;
导出默认类fullCalendar.Component{
建造师(道具){
超级(道具);
此.state={
weekendsVisible:没错,
当前事件:[],
成功:错,
危险:错,
currentId:null,
用户:[],
当前单击:[]
}
}
componentDidMount(){
此文件名为.retrieveUsers()
}
retrieveUsers(){
UserDataService.getAll()
。然后(响应=>{
这是我的国家({
用户:response.data
});
})
.catch(e=>{
控制台日志(e);
});
}
GetCongeWithId(id){
变量L=[]
初始事件。forEach(元素=>{
if(id==element.id){
L.push(对象值(元素))
}
})
返回L
}
render(){
返回(
卡朗德里耶
阿菲舍尔周末酒店
this.setState({danger:false})
color=“info”
>
{this.state.currentId==null?

: ( {this.state.users.map((option)=>(option.id==parseInt(this.GetCongeWithId(this.state.currentId)[0][4])? Employeeédu:{option.services[0]} :(

) ))}

)} {this.state.currentId==null?

: ( 雇佣名称:{this.GetCongeWithId(this.state.currentId)[0][7]}
使用名称:{this.GetCongeWithId(this.state.currentId)[0][8]}
雇员电话:{this.GetCongeWithId(this.state.currentId)[0][5]}
Solde de congéde l'Employee:{this.GetCongeWithId(this.state.currentId)[0][6]}jour(s)
Date de deébut du congé:{this.GetCongeWithId(this.state.currentId)[0][2]}
会议日期:{this.GetCongeWithId(this.state.currentId)[0][3]}

)} this.setState({danger:false}}>Fermer ) } handleWeekendsToggle=()=>{ 这是我的国家({ WeekendVisible:!this.state.WeekendVisible }) } handleDateSelect=(selectInfo)=>{ let title=prompt('请为事件输入新标题') 让calendarApi=selectInfo.view.calendar calendarApi.unselect()//清除日期选择 如果(标题){ calendarApi.addEvent({ id:“”, 标题 开始:选择info.startStr, 结束:selectInfo.endStr, 全天:选择info.allDay }) } } handleEventClick=(单击信息)=>{ 这是我的国家({ 危险:没错, currentId:parseInt(单击info.event.\u def.publicId) }) } handleEvents=(事件)=>{ 这是我的国家({ 时事:时事 }) } } 函数renderEventContent(事件信息){ 返回( {eventInfo.timeText} {eventInfo.event.title} ) }