-
Notifications
You must be signed in to change notification settings - Fork 27
useSubscription resubscribes on each message received #54
Comments
Actually, I think the real reason is that |
In order to provide stateful subscriptions that don't get reset with every message receipt, there needs to be a separation of subscription components BREAKING CHANGE: useSubscription no longer exists. use createSubscription instead. fix VictorHAS#54
Hey @Aposhian thanks again for the contribution, I was doing some testing on the alpha version and there is a big problem with webpack 5 and react too. what configuration are you using now? I think we can use precompiled-mqtt for temporary solution, what you think? I'll do some tests with you new createSubscription |
I have been getting it to work with Webpack 5 by replacing Create React App with react-app-rewired, and then using the following Webpack overrides:
|
Paho-MQTT seems to not have issues, but it would require switching libraries. |
Paho MQTT (for JavaScript) appears to not be actively maintained though: it hasn't had a commit in 3 years. |
Also, MQTT.js can be made to work just fine with Webpack 5: it just involves readding the polyfills that were removed by default. |
If I make a very simple component that displays data from a subscription, I have found that it resubscribes every time it receives a new message. This is inefficient, and causes extra latency. My guess is that because the Mqtt client is passed through the context, message receipt changes the client, which then causes the consumers of the mqtt context to rerender. I am looking into this right now.
The text was updated successfully, but these errors were encountered: