reactjseventsalertreact-big-calendaronselect

How can you display two event items in an alert for react-big-calander onSelectEvent


react-big-calander - NPM Package

https://github.com/intljusticemission/react-big-calendar/blob/master/examples/demos/selectable.js

onSelectEvent={event => alert(event.distance, 'info')}

in this example, I want to display event.distance as well as event.title in the alert, but alert only accepts one value. How would I be able to display both within same alert?

I've tried to create a new function that runs when the event is triggered though it did not work so I thought about using a modal instead.


Solution

  • Have you tried a template literal:

    onSelectEvent={event => alert(`${event.distance} ${event.title}`)}