How to hide previous month dates in current Month view in react-big-calender

73 views Asked by At

I'm new to react-big-calender. I want to hide the previous month's dates in the current month's view. Is there any way to remove the previous dates?

My code is below.

<Calendar
  // toolbar={false}
  localizer={localizer}
  events={myEventsList}
  startAccessor="start"
  endAccessor="end"
  style={{ height: 800 }}
  eventPropGetter={eventStyleGetter}
  view="month"
/>

Event List

I have Attached the image.Calender Image

Events with current Month

const eventLists = [
  {
    "title": "Event 6",
    "start": "2024-02-01T12:00",
    "end": "2024-02-01T13:00"
  },
  {
    "title": "Event 7",
    "start": "2024-02-03T13:00",
    "end": "2024-02-03T14:00"
  },
  {
    "title": "Event 8",
    "start": "2024-02-05T14:00",
    "end": "2024-02-05T15:00"
  },
  {
    "title": "Event 9",
    "start": "2024-02-07T15:00",
    "end": "2024-02-07T16:00"
  },
]

enter image description here

1

There are 1 answers

0
Steve -Cutter- Blades On

In the Month view, dates outside of the current month get a class of rbc-off-range. To remove the display of the 'date' from those cells you could apply an override class.

.rbc-off-range {
  > a {
    display: none;
  }
}

As you've already seen, this will still put any events on those cells, so it is up to you to programmatically remove them.