How we can Update events coming from api response
3 years ago.
when i am trying to add events coming from api response i am getting p.getTime is not a function error. but if i try to use events defined in file it works well. Could you please help me with issue
class Calendar extends Component {
constructor(props) {
super(props);
this.calendarRef = React.createRef();
this.state = {
viewType: "Week",
timeRangeSelectedHandling: "Enabled",
onEventClick: async args => {
const modal = await DayPilot.Modal.prompt("Update event text:", args.e.text());
if (!modal.result) { return; }
const e = args.e;
e.data.text = modal.result;
this.calendar.events.update(e);
},
};
}
calendar() {
return this.calendarRef.current.control;
}
componentDidMount() {
// load event data
this.setState({
startDate: "2022-11-11",
events: this.props.events
// [
// {
// id: 1,
// text: "Event 1",
// start: "2022-09-07T10:30:00",
// end: "2022-09-07T13:00:00"
// },
// {
// id: 2,
// text: "Event 2",
// start: "2022-09-08T09:30:00",
// end: "2022-09-08T11:30:00",
// barColor: "#6aa84f"
// },
// ]
});
}
render() {
return (
<DayPilotCalendar
{...this.state}
ref={this.calendarRef}
/>
);
}
}
DayPilot