Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// directly on the hub, which is managed with normal classes
// instead of waiting for react-render lifecycles
if (hub['hubConnection'].state !== ConnectionStatus.connected) {
/* private field. YOLO */
return;
}
try {
hub.send('UnsubscribeFrom', subscribeTo);
} catch (e) {
console.log(
'tried to unsubscribe: ',
subscribeTo,
isConnected,
hub['hubConnection'].state,
ConnectionStatus.connected
);
throw e;
}
};
}, [subscribeTo, isConnected, isSubscribed, hub]);
return () => {
if (subscription.current) {
subscription.current.unsubscribe();
}
if (!isConnected) return;
// NOTE: isConnected from the context provider doesn't
// propagate its update quick enough for this particular value
// of this particular copy of the reference to be correct /
// the most up to date. So we need to access the state
// directly on the hub, which is managed with normal classes
// instead of waiting for react-render lifecycles
if (hub['hubConnection'].state !== ConnectionStatus.connected) {
/* private field. YOLO */
return;
}
try {
hub.send('UnsubscribeFrom', subscribeTo);
} catch (e) {
console.log(
'tried to unsubscribe: ',
subscribeTo,
isConnected,
hub['hubConnection'].state,
ConnectionStatus.connected
);
throw e;
(state) => {
if (this.isDestroying) return;
this.setState({
isConnected: state.status === ConnectionStatus.connected,
connectionState: state,
});
}
);