Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

Unexpected token, expected "("?

$
0
0

I am working on a calendar and trying to use the react-native-calendar-events library to add events to the native iOS calendar but I seem to get an error saying that the createCalendarEvent() declaration is missing a "(". I am not sure where exactly I am missing it.

async function addToCalendar(event) {try {const startDate =  Platform.OS === "ios"    ? format(parse(event.StartDateLocal))    : parse(event.StartDateLocal);const endDate =  Platform.OS === "ios"    ? format(parse(event.EndDateLocal))    : parse(event.EndDateLocal);const allEvents = await RNCalendarEvents.fetchAllEvents(startDate, endDate);const calendarEvent = allEvents.find(e => e.title === event.Title);if (calendarEvent) {  alert("You have already added this event to your calendar.");} else {  const title = event.Title;  const {    Location: {      AddressLine1: address,      City: city,      StateAbbreviation: state,      PostalCode: zip    }  } = event;  const location = `${address}, ${city}, ${state}, ${zip}`;  const settings = {    location,    startDate,    endDate  };  RNCalendarEvents.saveEvent(title, settings)    .then(() => {      alert("Event Saved");    })    .catch(rejectionReason => {      console.log(rejectionReason);      alert("Oops! Something has gone wrong.");    });  }} catch (e) {alert(e.message);}}

Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>