There are two options:
1. You can use the direct API and load events using the update() method. This approach is used in the React Weekly Calendar tutorial:
https://code.daypilot.org/42221/react-weekly-calendar-tutorial
componentDidMount() {
// load event data
this.calendar.update({
events: [
{
id: 1,
text: "Event 1",
start: "2023-03-07T10:30:00",
end: "2023-03-07T13:00:00"
},
// ...
]
});
}
2. Another option is to use state. In this case the Calendar component will be updated automatically.
Example:
componentDidMount() {
// load event data
this.setState({
events: [
{
id: 1,
text: "Event 1",
start: "2022-11-08",
end: "2022-11-09"
},
// ...
]
});
}
render() {
return (
<div>
<DayPilotMonth
{...this.state}
/>
</div>
);
}
You can find an example in the React Monthly Calendar tutorial:
https://code.daypilot.org/26289/react-monthly-calendar-tutorial
You can choose either method but you shouldn't mix them. If you store events in the state and then load them using the direct API the changes will be overwritten when a state change is detected and applied.