CalendarContext provides access to the calendar state managed by CalendarProvider. Use this context to read the current date, selected date, and call methods to update the calendar state from any child component.
Import
Usage with useContext
Usage with asCalendarConsumer
For class components, use theasCalendarConsumer higher-order component:
Context properties
The current visible date in ‘yyyy-MM-dd’ format. This represents the month/week currently being displayed in the calendar.
The previous date before the last update in ‘yyyy-MM-dd’ format. Useful for detecting date changes and transitions.
The currently selected date in ‘yyyy-MM-dd’ format. This is the date highlighted as selected in the calendar.
The source of the last calendar update. Possible values:
'calendarInit'- Initial calendar setup'propUpdate'- Date prop changed'todayPress'- Today button pressed'dayPress'- Day was pressed'arrowPress'- Month arrow pressed'weekArrowPress'- Week arrow pressed'listDrag'- Agenda list scrolled'pageScroll'- Calendar scrolled'weekScroll'- Week calendar scrolled
Number of days displayed in timeline/week calendar mode. Only set when using multi-day views.
Left inset width for timeline calendar (sidebar width) in pixels. Default is 72.
Context methods
Updates the calendar to show and select a new date.Parameters:
date- Date string in ‘yyyy-MM-dd’ formatsource- Update source identifier (typically'dayPress'for programmatic updates)
Enables or disables the today button (if shown).Parameters:
disable- Whether to disable the today button
Complete example
TypeScript interface
Related
- CalendarProvider - Provider component that creates the context
- asCalendarConsumer - HOC for class components
- ExpandableCalendar - Calendar component that uses context