Full Calendar in React TypeError: Cannot read property 'calendar' of undefined
Full Calendar in React TypeError: Cannot read property 'calendar' of undefined
尝试在状态中存储有关所选时间的信息时出现错误。感谢您的帮助,感谢您的宝贵时间!如果你们需要更多具体信息,请告诉我。
以下是我的组件的代码片段:
const Calendar = (props) => {
const [startTime, setStartTime] = React.useState('');
const handleSelect = (selectedInfo) => {
//alert(selectedInfo.startStr);
setStartTime(selectedInfo.startStr);
}
return (
<FullCalendar
defaultView="timeGridWeek"
weekends={false}
allDaySlot={false}
plugins={[ timeGridPlugin, dayGridPlugin, interactionPlugin ]}
minTime="08:00:00"
selectable={true}
selectMirror={true}
selectOverlap={false}
select={handleSelect}
header={{
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay'
}}
events={[
{ title: 'event 1', start: '2020-03-16 10:00:00', end: '2020-03-16 12:00:00' },
{ title: 'event 2', start: '2020-03-19' }
]}
/>
);
}
export default class Calendar extends React.Component{
state = {startTime: ''}
handleSelect = (selectedInfo) => {
//alert(selectedInfo.startStr)
this.setState({ startTime: selectedInfo.startStr})
console.log("working!!", this.state.startTime)
}
render(){
return (
<FullCalendar
defaultView="dayGridMonth"
weekends={false}
allDaySlot={false}
plugins={[timeGridPlugin, dayGridPlugin, interactionPlugin]}
minTime="08:00:00"
selectable={true}
selectMirror={true}
selectOverlap={false}
select={this.handleSelect}
header={{
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay'
}}
events={[
{ title: 'event 1', start: '2020-03-16 10:00:00', end: '2020-03-16 12:00:00' },
{ title: 'event 2', start: '2020-03-19' }
]}
/>
)
}
}
我也遇到了同样的问题。同样的错误信息。我一直在网上搜索,我想到的解决方案是这样的。
将 fullcalendar
和 fullcalendar-react
升级到版本 4.4.1
为我解决了这个问题。它似乎是 bug.
尝试在状态中存储有关所选时间的信息时出现错误。感谢您的帮助,感谢您的宝贵时间!如果你们需要更多具体信息,请告诉我。
以下是我的组件的代码片段:
const Calendar = (props) => {
const [startTime, setStartTime] = React.useState('');
const handleSelect = (selectedInfo) => {
//alert(selectedInfo.startStr);
setStartTime(selectedInfo.startStr);
}
return (
<FullCalendar
defaultView="timeGridWeek"
weekends={false}
allDaySlot={false}
plugins={[ timeGridPlugin, dayGridPlugin, interactionPlugin ]}
minTime="08:00:00"
selectable={true}
selectMirror={true}
selectOverlap={false}
select={handleSelect}
header={{
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay'
}}
events={[
{ title: 'event 1', start: '2020-03-16 10:00:00', end: '2020-03-16 12:00:00' },
{ title: 'event 2', start: '2020-03-19' }
]}
/>
);
}
export default class Calendar extends React.Component{
state = {startTime: ''}
handleSelect = (selectedInfo) => {
//alert(selectedInfo.startStr)
this.setState({ startTime: selectedInfo.startStr})
console.log("working!!", this.state.startTime)
}
render(){
return (
<FullCalendar
defaultView="dayGridMonth"
weekends={false}
allDaySlot={false}
plugins={[timeGridPlugin, dayGridPlugin, interactionPlugin]}
minTime="08:00:00"
selectable={true}
selectMirror={true}
selectOverlap={false}
select={this.handleSelect}
header={{
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay'
}}
events={[
{ title: 'event 1', start: '2020-03-16 10:00:00', end: '2020-03-16 12:00:00' },
{ title: 'event 2', start: '2020-03-19' }
]}
/>
)
}
}
我也遇到了同样的问题。同样的错误信息。我一直在网上搜索,我想到的解决方案是这样的。
将 fullcalendar
和 fullcalendar-react
升级到版本 4.4.1
为我解决了这个问题。它似乎是 bug.