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

React Native support #184

Open
austingayler opened this issue Mar 23, 2023 · 4 comments
Open

React Native support #184

austingayler opened this issue Mar 23, 2023 · 4 comments

Comments

@austingayler
Copy link

austingayler commented Mar 23, 2023

Hi, I didn't see anywhere in the docs whether or not this library is assumed to be compatible with React Native. It might be helpful for those choosing a websocket library for their project to say if there are any known incompatibilities, or if it's good to go.

This library:
Sumit1993/react-native-use-websocket#27

says it works, but I haven't tested.

@WoonHaKim
Copy link

WoonHaKim commented May 9, 2023

When migrating to react 18(New RN architecture forces to use React 18), It seems like b52c5f9 can be RN not to work properly because of importing react-dom and using flushSync

@michaelbachmann
Copy link

Is it specific functionality that won’t work for version 4 in react native or will it just plain not work? Is it not advised to use this in a react native application?

I see there is a flag in the current code base for checking if we are in a react native environment to prevent EventSource feature in React Native. Which makes me think that ReactNative should be supported for useWebsocket?

export const isReactNative = typeof navigator !== 'undefined' && navigator.product === 'ReactNative';

@hazmah0
Copy link

hazmah0 commented May 24, 2024

I tried using this library in a react-native app and it mostly works for my use case. The only issue I have is that I can't set headers for the http upgrade request that occurs before switching protocols. This is an issue in iOS at least where the user agent header is not set and therefore the request gets blocked in the WAF.

I forked this repository to solve it for now but would love to see that feature getting added in. Is there any plans to do so @robtaussig?

@seba9999
Copy link

seba9999 commented Jun 3, 2024

I was trying to add this lib to a RN project but I've face some strange behaviour when installing with the dependency tree !
The lib itself has react@">= 18.0.0
BUT react-dom (That I don't even want in my React Native app !) has react@"^18.3.1"

Then I can't add it to my expo project ( SDK 51 ) 😢

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