- Notifications
You must be signed in to change notification settings - Fork1.4k
React Native Support#1841
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
In the version5.5.2 was fixed an issue that didn't allow use MQTT.js in React Native (RN). The motivation of this discussion is bring a example of how to implement MQTT.js in React Native and also maybe bring ideas of enhancements for RN environment. You can see the example inReact Native MQTT.js Implementation |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 4 comments 17 replies
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
@MaximoLiberata Thanks! Could you kindly add a link to this on readme please? |
BetaWas this translation helpful?Give feedback.
All reactions
-
Hi@robertsLando, thanks to you! I opened the PR#1842 |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
Wondering if this is still needed?https://github.com/MaximoLiberata/react-native-mqtt.js-example/blob/main/App.js#L8 |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Just to be sure, is react native using the browser bundle? If so I think this could be easily fixed by patching the esbuild bundle here:https://github.com/mqttjs/MQTT.js/blob/main/esbuild.js Maybe by adding a new entry on "define" or manually adding the polifilly on top of the output bundfle, could you guys do some tries? |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
I tried to use the browser bundle, but they threw a exeption:
React Native doesn't use the browser bundle, I think its behavior is closer to node.js than browser. Also, I tried to add a piece of code in the Not is the best solution, this change also modify the |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
I just tried adding this block or, same like inhttps://github.com/mqttjs/MQTT.js/blob/main/src/lib/connect/index.ts#L11 I think it fixed it, without needs to add it at top of RN App. If you can have a look to check if that might be a proper solution. |
BetaWas this translation helpful?Give feedback.
All reactions
-
@MaximoLiberata Did the last proposed solution fix the issue! |
BetaWas this translation helpful?Give feedback.
All reactions
-
Yes, I tested in the RN APP example and it worked well. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
Good, I think this update might work with releasev5.5.1 as a fix, I am not sure, needs to best tested. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Nope what I meant is if react is actually using the browser bundle or not, the bundle is automatically served based on the package.json I think that adding: to the connect/index.ts isn't so bad, someone wants to submit a PR? |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
@robertsLando So, I am not sure that other commits in (fc8fafb) are required, as no error appears for me at least. may be required for other issue. just this block in connect/index.ts, and importing Buffer even no need for importing isReactNativeBrowser() in connect/index.ts with regards to using setImmediate or setTimeout(callback, 0) |
BetaWas this translation helpful?Give feedback.
All reactions
-
Just to update, my issue was that process.nextTick is not a function was blocking my RN App to connect to the broker. So, just a PR is required to fix the process.nextTick is not a function error for RN Apps. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Another notice here, I did not get this error: Cannot create URL for blob (#1840) in my RN App; as I am setting timerVariant: "native" not "auto". |
BetaWas this translation helpful?Give feedback.
All reactions
-
Yeah that's the solution I suggested at start in the issue |
BetaWas this translation helpful?Give feedback.
All reactions
-
@robertsLando I just opened PR#1849. |
BetaWas this translation helpful?Give feedback.