ProSchedulerSign in

Scheduler · Localization & lifecycle

Event hooks

Every callback, logged as it fires, in order.

Live demo

Click, double-click and drag an event · Navigate a week

Fullscreen
import { ProScheduler } from "@andreisaac/pro-scheduler"
import { studioResources, studioSessions } from "./data/studio"
import { Log, useEvents, useLog, when } from "./kit"

export function EventHooksDemo() {
  const { events, handlers } = useEvents(studioSessions)
  const { lines, log } = useLog(10)

  return (
    <div className="docs-demo__stack">
      <ProScheduler
        data={events}
        resources={studioResources}
        view={{ scheduler: { type: "week", startTime: "07:00", endTime: "20:00" } }}
        showDefaultEditor={false}
        onEventClick={(e) => log(`onEventClick · ${e.title}`)}
        onEventDoubleClick={(e) => log(`onEventDoubleClick · ${e.title}`)}
        onCellClick={({ date }) => log(`onCellClick · ${when(date)}`)}
        onEventCreate={(d) => log(`onEventCreate · ${when(d.start)}`)}
        onEventCreated={(e) => {
          log(`onEventCreated · ${e.title}`)
          handlers.onEventCreated(e)
        }}
        onEventUpdate={(e) => log(`onEventUpdate · ${e.title}`)}
        onEventUpdated={(e) => {
          log(`onEventUpdated · ${e.title}`)
          handlers.onEventUpdated(e)
        }}
        onPageChange={({ firstDay }) => log(`onPageChange · week of ${firstDay.toLocaleDateString()}`)}
        onSelectedDateChange={(d) => log(`onSelectedDateChange · ${d.toLocaleDateString()}`)}
        height={500}
      />
      <Log lines={lines} empty="Click, drag or navigate…" />
    </div>
  )
}

About this demo

Every callback, logged as it fires, in order.

Things to try

  • Click, double-click and drag an event
  • Navigate a week

The props behind it are explained in API reference.

Use ProScheduler in your project