Comments (8)
Thanks for letting me know. Do you have a codesandbox that reproduces this?
from use-pusher.
@201524547 It was something i had reported time ago, it disconnects and never re-connects back to the channel if the component re-renders
@mayteio All you have to do is simply have a component that with a parent or some dependency that make it re-render and test having the useChannel with some useEvent and you'll notice the first time pusher invokes your callback its okay but the 2nd time after component gets re-rendered it just unbinds the channel (disconnecting or not) and the callbacks are no longer doing anything
from use-pusher.
Please provide a codesandbox - I do not have this issue.
from use-pusher.
Sure i'll do that but i think i found why its probably happening, let me explain it quickly
There are types of channels that need to be persisted while the application is on, usually those are bounded to the user itself and not to the component, useChannel makes it unsubscribe on unmount and what if a component uses a user room that needs to be alive while the app is running? That was in fact one of the issues, my workaround was creating a custom useChannel that just simply doesn't unsubscribe but removes the event only but i think there is room for improvement.
Do you think that considering a parameter option whether we can unsubscribe or not? It does make sense having it unsubscribing on unmount but sometimes you don't want that channel to go away in sub-components, not sure what's your suggestion in here. Once i have some free time i'll publish here the issue
from use-pusher.
Hey, why don’t you move the useChannel hook higher up into a provider? That way it can live connected for the duration of the session.
from use-pusher.
At some point if my event uses that channel somehow its unsubscribing, i tried that but i can check again
What i ended up doing is check if the channel exists and re-use but never close it (only the higher up provider) is closing it
but probably i might be doing something wrong
from use-pusher.
Might #43 solve this too?
from use-pusher.
yeah, I ran into the same problem and (as far as I can tell), #43 would solve this perfectly.
from use-pusher.
Related Issues (20)
- React 18: Property 'children' does not exist on type 'IntrinsicAttributes & PusherProviderProps'. HOT 1
- Encrypted Channels
- Update auth config is not working
- Small mistake in usePresenceChannel documentation HOT 3
- useChannel performance optimization HOT 4
- useEffect: data might not be optional in the callback HOT 2
- Working presence channel HOT 2
- Reconnect after activity timeout HOT 3
- Maintaining connection in react-router HOT 2
- feat: logToConsole HOT 3
- Warn/Error when an event is un-handled HOT 3
- Introduce <ChannelProvider /> to hoist channel connection HOT 6
- useChannel(false) to prevent eager channel connection HOT 4
- Connection does not disconnect when transitioning to another page.
- Move jest to dev dependencies
- Change the way of requiring pusher-js To enable private-encrypted channels HOT 1
- Does this package ignore presence ? HOT 1
- Package maintenance status HOT 12
- Incompatible with React versions >16 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from use-pusher.