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

EventEmitter in react-native 0.61 is not working as 0.60 #27413

Closed
kamelj opened this issue Dec 4, 2019 · 4 comments
Closed

EventEmitter in react-native 0.61 is not working as 0.60 #27413

kamelj opened this issue Dec 4, 2019 · 4 comments
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot. Type: Question Issues that are actually questions and not bug reports.

Comments

@kamelj
Copy link

kamelj commented Dec 4, 2019

When I using EventEmitter in react-native 0.61 I got this error:

Unable to resolve module EventEmitter from Main.js: EventEmitter could not be found within the project.

This is Main.js look like:

import _EventEmitter from 'EventEmitter';
export const EventEmitter = new _EventEmitter();

export const toast = (msg, duration = 4000) => { 
EventEmitter.emit(Constants.EmitCode.Toast, msg, duration) ;
};
@kamelj kamelj added the Type: Question Issues that are actually questions and not bug reports. label Dec 4, 2019
@react-native-bot
Copy link
Collaborator

We are automatically closing this issue because it does not appear to follow any of the provided issue templates.

👉 Click here if you want to report a reproducible bug or regression in React Native.

@react-native-bot react-native-bot added Ran Commands One of our bots successfully processed a command. Resolution: No Template labels Dec 4, 2019
@GunnarAK
Copy link

GunnarAK commented Jan 9, 2020

The magic you describe has been removed: #24316

To fix the import issue:

import EventEmitter from "react-native/Libraries/vendor/emitter/EventEmitter";

Searching EventEmitter.js in node_modules tells you the path. Same method can be applied on other imports having this type of error.
Example:

import type EmitterSubscription from "EmitterSubscription";

to

import type EmitterSubscription from "react-native/Libraries/vendor/emitter/EmitterSubscription";

@youssef212
Copy link

@GunnarAK solution saves the day but still this is an issue

@demedos
Copy link

demedos commented Sep 22, 2021

Still an issue on 0.64

@facebook facebook locked as resolved and limited conversation to collaborators Oct 2, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot. Type: Question Issues that are actually questions and not bug reports.
Projects
None yet
Development

No branches or pull requests

5 participants