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

Add support for react-native #657

Open
silencedcoder opened this issue Jun 14, 2018 · 18 comments
Open

Add support for react-native #657

silencedcoder opened this issue Jun 14, 2018 · 18 comments
Labels
O-Uncommon Most users are unlikely to come across this or unexpected workflow T-Enhancement

Comments

@silencedcoder
Copy link

I want to use it with react-native,but i cant't find the way which to do this.please help me. thank you.

@Sekhmet
Copy link

Sekhmet commented Aug 22, 2018

Please mention what does exactly not work for you, so others can help you if someone encountered the same problem.

@ara4n
Copy link
Member

ara4n commented Aug 22, 2018

there's no reason why js-sdk shouldn't work on react-native.

@jm90m
Copy link

jm90m commented Aug 22, 2018

thanks @ara4n, it works for me on react native with expo, me and @Sekhmet were working on this and we had to install the following libraries as dev dependancies on our end

yarn add --dev babel-plugin-transform-async-to-bluebird babel-preset-es2015

Also my console.log and emulator is filled with a bunch of these:
screen shot 2018-08-22 at 12 10 39 pm

But you guys might already know this :)

@jm90m
Copy link

jm90m commented Aug 25, 2018

@moeinrahimi looks like you're missing some dependancies, try installing the ones I had above... also are you using vanilla React Native? or React Native with Expo?

@jm90m
Copy link

jm90m commented Aug 25, 2018

try using expo @moeinrahimi, https://expo.io/, and see if it works with that, other than that, I would try to clear your node modules and do a fresh yarn

@jm90m
Copy link

jm90m commented Aug 29, 2018

@moeinrahimi You are going to need to polyfill it.. see solution here - expo/browser-polyfill#10

@Ryuno-Ki
Copy link
Contributor

@moeinrahimi It could help others if you'd take some time to list the installed polyfills. Thank you.

@turt2live turt2live added the T-Other Questions, user support, anything else label Dec 6, 2018
@nikhiltechzillaindiacom
Copy link

nikhiltechzillaindiacom commented Apr 25, 2019

npm i events url buffer worked for me

@annie-elequin
Copy link

annie-elequin commented Jul 15, 2019

I wrote an article about how to fix the earlier "Unable to resolve module 'events'" issue.

However I'm running into a new problem - when I try to run expo publish, I get an error about an "unterminated string constant in unhomoglyph.json".

"unhomoglyph" is a library that matrix is specifically using in their project. I have posted issues about this on both matrix github and unhomoglyph github (Found here) and typically people have not been willing to look into it.

I'm starting to lose hope that the matrix-js-sdk can work with React Native after all. Has anybody else run into this? @moeinrahimi , how far did you get with getting the sdk to work with react native?

@hannojg
Copy link

hannojg commented Jan 2, 2020

I was thinking about using the native android and iOS matrix client SDKs and writing a wrapper for react-native.
This way we could take advantage of the optimized native implementations.

@rajscet
Copy link

rajscet commented Jan 25, 2021

I was thinking about using the native android and iOS matrix client SDKs and writing a wrapper for react-native.
This way we could take advantage of the optimized native implementations.

any update?

@annie-elequin
Copy link

annie-elequin commented Jan 25, 2021

I was thinking about using the native android and iOS matrix client SDKs and writing a wrapper for react-native.
This way we could take advantage of the optimized native implementations.

any update?

@rajscet

https://github.com/cuvent/react-native-matrix-sdk

@jpschw
Copy link

jpschw commented Jul 3, 2022

This polyfill almost works. Now I get an error regarding webRTC not being supported by the browser. Any ideas?

@throwaway34241
Copy link

Is supporting RN still on the roadmap?

Today, use 23.1.1, importing import sdk from "matrix-js-sdk"; in a fresh Expo project gives the following error:

Android Bundling complete 64ms
 ERROR  ReferenceError: Can't find variable: Intl
 ERROR  Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 11): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient, RCTEventEmitter.
        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.
 ERROR  Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 11): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient, RCTEventEmitter.
        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.

@t3chguy
Copy link
Member

t3chguy commented Jan 30, 2023

Is supporting RN still on the roadmap?

Sorry, where was it ever stated that it was? This library is intended for Web & Node. It'll work in many more places than that with a bit of extra work using Node polyfills.

@throwaway34241
Copy link

throwaway34241 commented Jan 30, 2023

Sorry for the confusion, I'm new here, saw comments like #657 (comment) and jumped to conclusions. Thanks for clearing up that React Native is not officially supported.

@sagarsq
Copy link

sagarsq commented May 1, 2024

Does it have React Native support now?

@richvdh richvdh changed the title how can i use it with react-native Add support for react-native Jan 2, 2025
@richvdh richvdh added T-Enhancement O-Uncommon Most users are unlikely to come across this or unexpected workflow and removed T-Other Questions, user support, anything else labels Jan 2, 2025
@richvdh
Copy link
Member

richvdh commented Jan 2, 2025

Currently, it's probably possible to get most of js-sdk working in React Native with sufficient babel/polyfill magic, but:
(a) IStore and the cryptography store rely on indexeddb, which AIUI is not available in that environment (cf #4570, matrix-org/matrix-rust-sdk-crypto-wasm#168)
(b) There is no documentation of the the required polyfills/babel settings.
(c) We have no CI for this, and do not use RN internally, so even if the above gets fixed, it's unlikely to stay fixed for long.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-Uncommon Most users are unlikely to come across this or unexpected workflow T-Enhancement
Projects
None yet
Development

No branches or pull requests

16 participants