react-native-calendar-events: Undefined is not an object

Hi, I have been trying for a while to get this module to work in React Native and every time I run RNCalendarEvents.authorizationStatus() .then(status => { // handle status }) .catch(error => { // handle error });

I get the error that ‘undefined is not an object’

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 18 (10 by maintainers)

Most upvoted comments

Come to think of it, this change is easier:

'use strict';

import { NativeModules } from 'react-native';

var RNCalendarEvents = NativeModules.RNCalendarEvents;

export default RNCalendarEvents;

OK, figured it out. Using commonJS or other package systems may cause this.

It’s the difference on how you define the package in index.android and index.ios

Example to make it work in index.ios.js

'use strict';

import { NativeModules } from 'react-native';

var RNCalendarEvents = NativeModules.RNCalendarEvents;

export default {
    authorizationStatus() {
        return RNCalendarEvents.authorizationStatus()
    },

    async authorizeEventStore() {
        return RNCalendarEvents.authorizeEventStore()
    },

    async saveEvent(title, details) {
        return RNCalendarEvents.saveEvent(title, details)
    },
}

Just need to make it consistent between the two either export default or module.exports

Sure: The error is undefined is not an object(evaluating '_reactNativeCalendarEvents2.default.authorizeEventStore')

and the code is class WDReactNative extends Component{componentDidMount(){RNCalendarEvents.authorizeEventStore() .then(status=>{// handle status}) .catch(error=>{// handle error});}return (

and then I have a <View> and some <Text> etc… but right now I’m just trying to authorize then from there fetch events @wmcmahan

btw. sorry the code is minified, I was having some problems with that

OK, if this package has been properly linked this to the project libraries then you should be able to reference it in your JS module. Double check its listed as a library under “build phases”.