FullCalendar React Component

repository·main·Indexed 25 days ago

https://github.com/fullcalendar/fullcalendar-react

The official React component for FullCalendar (version 6.1.21), providing a bridge between the FullCalendar core engine and React applications. It allows developers to render the FullCalendar component using CalendarOptions as props and access the underlying CalendarApi instance via the getApi() method.

Tokens
623
Snippets
2
Records
4
Agent score
32%

What's inside FullCalendar React

  1. Use the FullCalendar component in React

    main

    Render the FullCalendar component and pass FullCalendar options directly as props. You must provide a plugins array containing the plugins you have installed.

    import FullCalendar from '@fullcalendar/react'
    import dayGridPlugin from '@fullcalendar/daygrid'
    
    const events = [
      { title: 'Meeting', start: new Date() }
    ]
    
    export function DemoApp() {
      return (
        <div>
          <h1>Demo App</h1>
          <FullCalendar
            plugins={[dayGridPlugin]}
            initialView='dayGridMonth'
            weekends={false}
            events={events}
            eventContent={renderEventContent}
          />
        </div>
      )
    }
    
    // a custom render function
    function renderEventContent(eventInfo) {
      return (
        <>
          <b>{eventInfo.timeText}</b>
          <i>{eventInfo.event.title}</i>
        </>
      )
    }
  2. Install the FullCalendar React component

    main

    To use FullCalendar in a React project, you must install the React connector (@fullcalendar/react), the core engine (@fullcalendar/core), and the specific plugins you intend to use (e.g., @fullcalendar/daygrid).

    npm install @fullcalendar/react @fullcalendar/core @fullcalendar/daygrid
  3. Use the FullCalendar component

    main

    The FullCalendar component is the primary entry point for integrating FullCalendar into a React application. It accepts CalendarOptions as props, which are the standard configuration options used by the core FullCalendar library.

    To interact with the underlying FullCalendar instance (for example, to call methods like .next(), .prev(), or .refetchEvents()), you can use the getApi() method provided by the component instance.