I use a react router with a stream architecture (implementation of a stream of facebooks).
Currently, there is a route on my system that says "chat /: topic".
When a user enters this component, I create a subscription (using action creation, on componentWillMount) to the websocket server, and I remove the subscription to componentWillUnmount.
When a user moves to another route, the whole workflow works fine - because the reacting router disables my component.
When I go to my route (from "chat / games" to "chat / tv"), the component is not mounted, and I need to clear the state of the components.
I read about the various actions that I can take, and this is when I switch to sending the “TRANSIT” action, and each corresponding store will clear it.
In my opinion, this kind of action is wrong, it connects my stores and my router.
How would you solve this problem? Is this a problem that I have to raise to respond to the router and ask them to disconnect inside my route?
source
share