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

5.0.3 release broken for react native, downgrade to 5.0.2 #1672

Closed
grizmio opened this issue Aug 16, 2023 · 9 comments
Closed

5.0.3 release broken for react native, downgrade to 5.0.2 #1672

grizmio opened this issue Aug 16, 2023 · 9 comments

Comments

@grizmio
Copy link

grizmio commented Aug 16, 2023

For those using version 5.0.3 in react native and getting
"Error: ws does not work in the browser. Browser clients must use the native WebSocket object"
just downgrade to 5.0.2 and it will work.
npm i --save [email protected]

@robertsLando
Copy link
Member

@grizmio What's the value of process.title in react native? I have a feel this is due to this commit: 183b35a

I can revert part of that to keep the react native compatibility

@stephanbruny
Copy link

Couldn't the mode (browser or node process) be set by the user?
This way we could set the mode explicitly instead of implicitly by trying to figure out the current process platform

@robertsLando
Copy link
Member

robertsLando commented Aug 17, 2023

We could think about adding an env var for that.

Anyway please let me know:

What's the value of process.title in react native?

@robertsLando
Copy link
Member

@stephanbruny news on this?

@tanoc
Copy link

tanoc commented Sep 4, 2023

I think there is no title in process in react-native, so undefined

@robertsLando
Copy link
Member

I wonder how this: 183b35a

Could have broken react native so. Maybe it's the webpack thing? Is there any other way to detect react native?

@tanoc
Copy link

tanoc commented Sep 4, 2023

Stackoverflow says this: typeof navigator !== 'undefined' && navigator.product === 'ReactNative'

@robertsLando
Copy link
Member

@tanoc @grizmio @stephanbruny I suggest to use:

import * as mqtt from 'mqtt/dist/mqtt'

Let me know id that works

@robertsLando
Copy link
Member

FYI starting from 5.2.1 you can now import mqtt using:

import mqtt from 'mqtt'

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

4 participants