Skip to main content
EventProvider loads one event and exposes it — plus bound actions — to descendants via useEvent. It’s the simplest way to build an event detail page: the provider fetches the event (or accepts a pre-fetched one), and useEvent gives you the event state and callbacks that keep it in sync. There is no Redux store behind this — state is local to the provider. For lists, use useFetchManyEventsWrapper instead.

EventProvider

Identify the event by eventId, or pass a pre-fetched event object to skip the initial fetch.

Props

string
UUID of the event to load. Use this or event.
Event
A pre-fetched event object. Skips the initial fetch. Use this or eventId.
EventIncludeParam
Associations to expand on the fetch, as a single value or an array: "user", "space", "files", "userRsvp". Only used with eventId.
EventProvider renders null if neither eventId nor a valid event is provided.

useEvent

Call useEvent inside a descendant of EventProvider.

Return Values

Event | null | undefined
The loaded event. undefined while loading, null if not found or inaccessible — also after the event is deleted, and after a cancel or withdraw answers with a short body because the user can no longer see it. Such an event stays null for that eventId: the provider doesn’t fetch it again.
React.Dispatch<SetStateAction<Event | null | undefined>>
Directly set the event state. Useful for optimistic local updates.
(changes: Omit<UpdateEventProps, "eventId">) => Promise<Event | undefined>
Update the event’s mutable fields. Takes the changes alone, e.g. updateEvent({ capacity: 150 }): the fields of useUpdateEvent without eventId, including coverFile, images, files and removeFileIds. Hosts only, and on an event in a space only while they are active members of it. The response is merged onto the local event on success.
() => Promise<void>
Delete the event. Allowed for its owner and the space’s admins and moderators (and, on an event whose owner’s account was deleted, its hosts). Sets event to null on success.
() => Promise<CancelEventResponse | undefined>
Cancel the event (status: "cancelled"). Allowed for the same users as delete. Resolves with the event (merged onto the local one), or with { id, status: "cancelled" } when the user can’t see the event, which sets event to null.
(status: RsvpStatus) => Promise<Event | undefined>
Set/change the caller’s RSVP ("going" | "maybe" | "not-going"). Capacity-checked for going.
() => Promise<WithdrawRsvpResponse | undefined>
Withdraw the caller’s RSVP. Resolves with the event (merged onto the local one), or with { id, userRsvp: null } when the user can no longer see the event, which sets event to null.
Every full-event response (update, cancel, RSVP, withdraw) is merged onto the loaded event, so the space and files it was fetched with stay, and the result is kept for when the hook comes back to the same eventId.
These bound actions wrap the standalone hooks and handle errors internally (logging and returning undefined). For host/invite management (useAddHost, useAddInvite, …) and guest-list reads, use the standalone hooks alongside the provider.

See Also