Parse-SDK-JS
Parse-SDK-JS copied to clipboard
ReactNative - EventEmitter bug
New Issue Checklist
- [x] I am not disclosing a vulnerability.
- [x] I am not just asking a question.
- [x] I have searched through existing issues.
- [x] I can reproduce the issue with the latest versions of Parse Server and the Parse JS SDK.
Issue Description
Unable to use Parse in React Native 0.65.1
Steps to reproduce
- Create an empty React Native 0.65.1 iOS project
- Import Parse React Native:
import Parse from 'parse/react-native';
Actual Outcome
Error:
/../node_modules/react-native/Libraries/vendor/emitter/EventEmitter.js:15
import type {EventSubscription} from './EventSubscription';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at
Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/../node_modules/parse/lib/react-native/EventEmitter.js:1:20)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
Environment
- React Native iOS version:
0.65.1
Client
- Parse JS SDK version:
3.3.0
Thanks for opening this issue!
- ❌ Please edit your post and use the provided template when creating a new issue. This helps everyone to understand your post better and asks for essential information to quicker review the issue.
Please note that I have tried everything in all the related and/or duplicated issues.
@davimacedo should this issue stay in this repo or be moved to the react repo?
This issue belongs to this repo. @camdagr8 are you using cli or expo?
React-Native 0.70.0 Simplified and rewrote the EventEmitter. Can you try updating?
https://github.com/facebook/react-native/commit/e5c5dcd9e26e9443f59864d9763b049e0bda98e7
For those still having errors with this and landing here (probs because they still on an older version of Parse, like myself)
The API of the rewrote EventEmitter is the same, so it seems to work just patch-patching EventEmitter.js
to use the default export:
-var EventEmitter = require('../../../react-native/Libraries/vendor/emitter/EventEmitter');
+var EventEmitter = require('../../../react-native/Libraries/vendor/emitter/EventEmitter').default
@camdagr8, @ivnnv could you test out https://github.com/parse-community/Parse-SDK-JS/pull/1999 and let us know whether is solves the issue before we merge?
@mtrezza Their issues were solved before #1999
@ivnnv Issue was fix by removing the hard-coded path https://github.com/parse-community/Parse-SDK-JS/pull/1930 @camdagr8 Issue should be fixed by updating to the latest version of react-native > 0.70.0. It fixed the typescript import issue.
So if this issue has been solved, can we close it? And why is #1999 pointing to this issue if it's solved?
You can close it. I didn’t realized this was solved until just know. Any import issues involving live query is most likely event emitter related.
Closing, see explanation above.
So #1999 is actually a new feature that doesn't have an issue yet, right?