Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Basic setup of react-big-calendar events not showing

Im trying to use the react-big-calendar package. http://intljusticemission.github.io/react-big-calendar/examples/index.html

I have the calendar displaying on the page. The pagination is working and I have no errors in my console. However none of my events are showing. Do I have a syntax / format error somewhere?

import React from 'react';
import BigCalendar from 'react-big-calendar';
import moment from 'moment';

BigCalendar.momentLocalizer(moment); // or globalizeLocalizer


const Calendar = props => {
  const dummyEvents = [
    {
      allDay: false,
      end: new Date('December 10, 2017 11:13:00'),
      start: new Date('December 09, 2017 11:13:00'),
      title: 'hi',
    },
    {
      allDay: true,
      end: new Date('December 09, 2017 11:13:00'),
      start: new Date('December 09, 2017 11:13:00'),
      title: 'All Day Event',
    },
  ];
  return (
     <div>
         <BigCalendar
          events={dummyEvents}
          startAccessor="startDate"
          endAccessor="endDate"
        />
     </div>
  )
}
like image 425
Evanss Avatar asked Feb 02 '26 02:02

Evanss


2 Answers

You need to set a height or min height on the calendar:

.rbc-calendar {
  min-height: 600px;
}



const dummyEvents = [
    {
      allDay: false,
      end: new Date('December 09, 2017 20:00:00'),
      start: new Date('December 09, 2017 06:00:00'),
      title: 'hi',
    }
]
like image 174
Evanss Avatar answered Feb 04 '26 01:02

Evanss


Must add height for calendar container element. If you do not add height for calendar container, calendar won't be visible.

Must read the doc for react-big-calendar: https://github.com/intljusticemission/react-big-calendar

.rbc-calendar {
  min-height: 500px ;
}

<div className="rbc-calendar">
     <BigCalendar
      events={dummyEvents}
      startAccessor="startDate"
      endAccessor="endDate"
    />
 </div>
like image 24
Hassan Ajaz Avatar answered Feb 04 '26 00:02

Hassan Ajaz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!