Skip to main content

Overview

useEvent reads the event loaded by EventProvider from context, returning the event plus bound actions (updateEvent, deleteEvent, cancelEvent, setRsvp, withdrawRsvp). useEventData is the underlying hook the provider uses — call it directly when you want the same managed state without the provider/context.

useEvent

Call inside a descendant of EventProvider.
useEvent returns a Partial<UseEventDataValues> (empty object outside a provider).

useEventData

Manage an event without the provider. Pass either a pre-fetched event or an eventId to fetch.

Parameters

Event
A pre-fetched event. Use this or eventId.
string
An event ID to fetch. Use this or event.
string | string[]
Associations to expand when fetching by eventId.

Returns (both hooks)

Event | null | undefined
The event. undefined while loading, null if not found.
React.Dispatch
Set the event state directly (optimistic updates).
(props: { update }) => Promise<Event | undefined>
Update mutable fields (host-only).
() => Promise<void>
Delete the event (host-only).
() => Promise<Event | undefined>
Cancel the event (host-only).
(status: RsvpStatus) => Promise<Event | undefined>
Set/change the caller’s RSVP.
() => Promise<Event | undefined>
Withdraw the caller’s RSVP.

See Also