-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
[BUG] If Device A publishes again after initial load, it disconnects from Device B #66
Comments
Interesting, I haven't experienced this dropping in my production apps. Do you experience the issue with the app open on both devices and the message suddenly dropping? Is there some kind of rerender or maybe it has to do with how you've implemented the logic? Are you using hooks? |
Hey @LeviWilliams , yeah this happens when the app is open on both devices. I modified the example app to give this a try.. I'm still new with hooks so I might've made a mistake somewhere:
|
Well, I put the TextInput component directly in the return statement, changed |
Actually, upon doing this several times, the issue occurred again. I reverted back to the original example, published a simple string with a button component, and I ran into the same issue.. Do we have to do anything before publishing a message again? |
@alexzkazu Yes, if you're switching what you're publishing or the component is remounting before a new publish you need to call "unpublish()" to make sure all existing publications are removed. "Make sure to unpublish, disconnect and remove any listeners as they won't be removed automatically!" - from the docs. Just a piece of advice too - from what I can gather there this is kind of a complex way to achieve what you're trying to do. I would isolate the text input just so it's strictly a component and doesn't handle any logic and have a useEffect hook waiting for a new message or just pass down your publish logic function through props into the component. Then it's a lot easier to debug and see the flow as well. Seems to be a problem with how you're implementing it. |
Bug
Describe the bug
When I try to publish a stringified object on Device A after it published on the initial load, it seems to drop Device A's connection with Device B
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Device A and Device B should remain connected after the subsequent publish
Logs
The text was updated successfully, but these errors were encountered: