React-big-calendar: Surfacing events from agenda view

Created on 24 Jan 2017  路  2Comments  路  Source: jquense/react-big-calendar

Hi,

I'd like to know if it is possible for the component that instantiates the calendar to receive events from a button in a custom agenda view? I have an agenda view with an "add to my schedule" button and I would like to be able to determine that an agenda item has been clicked on in order to manage state in the parent component.

I can't seem to pass props or callback functions to the agenda view and it appears that onSelectSlot and onSelectEvent only apply to calendar cells and not agenda items.

Thanks in advance for any help or pointers to example code.

Most helpful comment

In case it's useful, I ran into a similar problem. I wanted my sidebar to show the event detail when an agenda item was clicked. Here's the relevant snippets:

* Parent.js (where state is managed) *
_custom function_

onSelectAgendaEvent = (event) => {
    // do something
    // e.g. this.setState({ selectedEvent: event });
  }

...
_pass the function to the custom component as props_

function MyAgendaComponentWithProps() {
    return <MyAgendaComponent
         ...
         onSelectAgendaEvent={() => onSelectAgendaEvent(event)}
     />
}

...

<BigCalendar
        events={events}
        onSelectEvent={onSelectEvent}
        ... 
        components = { agenda: { event: MyAgendaComponentWithProps } }
        onSelectAgendaEvent={onSelectAgendaEvent}
      />

* MyAgendaComponent.js *

const MyAgendaComponent = ({
  event,
  ...
  onSelectAgendaEvent,
}) => (
  <div >
    <h1 >{event.title} </h1>
      <button onClick={onSelectAgendaEvent}>Click Me</button>
  </div>
);

All 2 comments

In case it's useful, I ran into a similar problem. I wanted my sidebar to show the event detail when an agenda item was clicked. Here's the relevant snippets:

* Parent.js (where state is managed) *
_custom function_

onSelectAgendaEvent = (event) => {
    // do something
    // e.g. this.setState({ selectedEvent: event });
  }

...
_pass the function to the custom component as props_

function MyAgendaComponentWithProps() {
    return <MyAgendaComponent
         ...
         onSelectAgendaEvent={() => onSelectAgendaEvent(event)}
     />
}

...

<BigCalendar
        events={events}
        onSelectEvent={onSelectEvent}
        ... 
        components = { agenda: { event: MyAgendaComponentWithProps } }
        onSelectAgendaEvent={onSelectAgendaEvent}
      />

* MyAgendaComponent.js *

const MyAgendaComponent = ({
  event,
  ...
  onSelectAgendaEvent,
}) => (
  <div >
    <h1 >{event.title} </h1>
      <button onClick={onSelectAgendaEvent}>Click Me</button>
  </div>
);
Was this page helpful?
0 / 5 - 0 ratings

Related issues

crashspringfield picture crashspringfield  路  4Comments

manutenfruits picture manutenfruits  路  3Comments

nicolasriccardi picture nicolasriccardi  路  3Comments

The-Oracle picture The-Oracle  路  3Comments

gsavvid picture gsavvid  路  3Comments