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

Investigate the possibility of having Realm Web work in React Native #4178

Open
tomduncalf opened this issue Dec 29, 2021 · 4 comments
Open

Comments

@tomduncalf
Copy link
Contributor

tomduncalf commented Dec 29, 2021

As per #4174, trying to use Realm Web inside a React Native app throws an error: Can't find variable: TextDecoder. Adding https://www.npmjs.com/package/react-native-polyfill-globals gets further, but we then hit an error {{ WARN Invalid responseType: blob}}.

If it is possible to make Realm Web work inside React Native, this could be beneficial for users who would like to create a React Native app using Realm which also targets web (see #4177), if offline/sync support is not important (they would need to use Realm Web instead of RealmJS).

@hipaven
Copy link

hipaven commented Jan 12, 2022

I got similar error

import { ApolloClient, HttpLink, InMemoryCache } from "@apollo/client";
import * as Realm from "realm-web";

I am using above 2 realm features to call realm Graphql API in react native
Initially I got Error: While trying to resolve module @apollo/client. I added 'cjs' in metro config sourceexts. Now I am getting below error - . I assume the issue is with realm-web. Can you assist to resolve this issue.
ReferenceError: Property 'TextDecoder' doesn't exist, js engine: hermes
ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that
the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes
ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that
the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes.
ReferenceError: Property 'TextDecoder' doesn't exist, js engine: hermes
ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that
the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes
ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that
the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes

@ahmed-adly-khalil
Copy link

were anyone able to solve this? having same issue with https://github.com/nats-io/nats.ws

@mfrfinbox
Copy link

To solve the problem, install the "text-encoding-polyfill" and add the import statement "import 'text-encoding-polyfill'" to your index.js file as early as possible in your app. At least this worked for me, I hope it helps.

@elainema
Copy link

@mfrfinbox, the solution works for me, thanks

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

No branches or pull requests

5 participants