anycable-client icon indicating copy to clipboard operation
anycable-client copied to clipboard

Use with React Strict Mode

Open mattparlane opened this issue 9 months ago • 1 comments

Hi there...

Is there any best practice for use with Strict Mode? I am working on a chat application and I am receiving messages twice. If I try to do this:

useEffect(() => {
  ...

  return () => {
    cable.unsubscribe(channel);
  };
});

I get errors that the channel is unsubscribed.

Any ideas? Thanks!

mattparlane avatar Mar 21 '25 01:03 mattparlane

You should use channel.disconnect() instead of cable.unsubscribe(channel) to avoid double-unsubscribe errors.

Re: receiving twice. Could you please share the full snippet related to AnyCable?

palkan avatar Mar 26 '25 18:03 palkan