Parse-SDK-JS icon indicating copy to clipboard operation
Parse-SDK-JS copied to clipboard

ReactNative - EventEmitter bug

Open camdagr8 opened this issue 2 years ago • 4 comments

New Issue Checklist

Issue Description

Unable to use Parse in React Native 0.65.1

Steps to reproduce

  1. Create an empty React Native 0.65.1 iOS project
  2. 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

camdagr8 avatar Sep 12 '21 08:09 camdagr8

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.

camdagr8 avatar Sep 12 '21 08:09 camdagr8

@davimacedo should this issue stay in this repo or be moved to the react repo?

mtrezza avatar Oct 18 '21 18:10 mtrezza

This issue belongs to this repo. @camdagr8 are you using cli or expo?

davimacedo avatar Oct 18 '21 22:10 davimacedo

React-Native 0.70.0 Simplified and rewrote the EventEmitter. Can you try updating?

https://github.com/facebook/react-native/commit/e5c5dcd9e26e9443f59864d9763b049e0bda98e7

dplewis avatar Feb 04 '23 01:02 dplewis

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

ivnnv avatar Feb 13 '23 01:02 ivnnv

@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 avatar Aug 27 '23 23:08 mtrezza

@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.

dplewis avatar Aug 29 '23 22:08 dplewis

So if this issue has been solved, can we close it? And why is #1999 pointing to this issue if it's solved?

mtrezza avatar Aug 29 '23 22:08 mtrezza

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.

dplewis avatar Aug 29 '23 22:08 dplewis

Closing, see explanation above.

So #1999 is actually a new feature that doesn't have an issue yet, right?

mtrezza avatar Aug 29 '23 22:08 mtrezza