React-big-calendar: How to delete event in calendar

Created on 24 Sep 2018  路  1Comment  路  Source: jquense/react-big-calendar

Do you want to request a _feature_ or report a _bug_?

What's the current behavior?

What's the expected behavior?

Most helpful comment

I managed to do this the other day...

In your Calendar object you need an action assigned to the OnSelectEvent:

onSelectEvent = {event => this.onSelectEvent(event)} //Fires selecting existing event

Then I created a handler for the action:

//Clicking an existing event allows you to remove it
onSelectEvent(pEvent) {
   const r = window.confirm("Would you like to remove this event?")
   if(r === true){

     this.setState((prevState, props) => {
       const events = [...prevState.events]
       const idx = events.indexOf(pEvent)
       events.splice(idx, 1);
       return { events };
     });
   }
 }

Hope that helps

>All comments

I managed to do this the other day...

In your Calendar object you need an action assigned to the OnSelectEvent:

onSelectEvent = {event => this.onSelectEvent(event)} //Fires selecting existing event

Then I created a handler for the action:

//Clicking an existing event allows you to remove it
onSelectEvent(pEvent) {
   const r = window.confirm("Would you like to remove this event?")
   if(r === true){

     this.setState((prevState, props) => {
       const events = [...prevState.events]
       const idx = events.indexOf(pEvent)
       events.splice(idx, 1);
       return { events };
     });
   }
 }

Hope that helps

Was this page helpful?
0 / 5 - 0 ratings

Related issues

manutenfruits picture manutenfruits  路  3Comments

The-Oracle picture The-Oracle  路  3Comments

nicolasriccardi picture nicolasriccardi  路  3Comments

mathieusanchez picture mathieusanchez  路  4Comments

martinnov92 picture martinnov92  路  3Comments