Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for RN 0.18 #9

Closed
wants to merge 2 commits into from
Closed

Fix for RN 0.18 #9

wants to merge 2 commits into from

Conversation

asommer70
Copy link

Good morning,

I recently upgraded a project to React Native 0.18 and ran into this error:

Module RCTNativeAppEventEmitter is not a registered callable module.

After some digging I figured out that it was the Calendar Reminders module and found this issue. I then changed the sendAppEvent calls to sendDeviceEvent and things worked.

Making that change also fixed the warnings I was getting:

Warning: Failed propType: Invalid prop `date` of type `Number` supplied to `RCTDatePicker`, expected instance of `Date`
ExceptionsManager.js:76 Warning: Failed propType: Required prop `onDateChange` was not specified in `RCTDatePicker`. Check the render method of `DatePickerIOS`

Not 100% sure if those warnings have to do with the Reminders module or the DatePicker module, but either way they went away when I made the change.

Also, from the 918 issue there might be another way to solve the RCTNativeAppEventEmitter error, but I didn't spend a whole lot of time tracking that down since changing to the DeviceEventEmitter solved the problem.

Thanks,
Adam

@wmcmahan
Copy link
Owner

Thats strange. I'm currently on version 18.1, but can't seem to repro the error. Are you listening for event named EventReminder with the NativeAppEventEmitter module?

import {NativeAppEventEmitter} from 'react-native';

...

NativeAppEventEmitter.addListener('EventReminder', (reminders) => {});

@asommer70
Copy link
Author

Well that's good news that you're not having the same error, but I guess that means it's my setup then. I am using EventEmitter and not 100% sure of what I'm doing so it's entirely possible I'm doing things wrong.

I'm passing around an EventEmitter via props and using that to send events to other components:

var EventEmitter = require('EventEmitter');
var Subscribable = require('Subscribable');

...

  componentWillMount: function() {
    this.eventEmitter = new EventEmitter();

    this.addListenerOn(this.eventEmitter, 'got-habits', (habits) => {
      this.setState({habits: habits}, () => {
      });
    });
  },

Is there another way to use custom Events inside React Native?

@wmcmahan
Copy link
Owner

Looking in the header file and the js module sendAppEventWithName and sendDeviceEventWithName seem to only be different in naming conventions, with sendAppEventWithName used for "application-specific events" and sendDeviceEventWithName used for "device or iOS events". With that said, I'm not sure why changing methods fixes your issue, but I'll keep trying to repro this.

As far as creating custom events, it looks like you are following the proper pattern. I personally use Redux and actions over emitting events.

@wmcmahan
Copy link
Owner

Closing this since it appears to be resolved by including RN's NativeAppEventEmitter module, referenced in issue #10

@wmcmahan wmcmahan closed this Feb 13, 2016
@asommer70
Copy link
Author

Cool, thanks Will.

On Sat, Feb 13, 2016, 10:32 AM Will McMahan notifications@github.com
wrote:

Closing this since it appears to be resolved by including RN's
NativeAppEventEmitter module, referenced in issue #10
#10


Reply to this email directly or view it on GitHub
#9 (comment)
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants