[React Native] Disconnect error in v4

I am using v4 JS SDK with React Native.

{
   "@sendbird/chat": "^4.0.3",
   "react-native": "0.68.2"
}

I am getting the following error while trying to call sb.disconnect()

[TypeError: window.removeEventListener is not a function. (In 'window.removeEventListener("visibilitychange", this._toggleState.bind(this), {
        capture: !0
      })', 'window.removeEventListener' is undefined)]

my code snippet

 const disconnectSendbird = useCallback(() => {
    if (sendbirdChannelRef.current) {
      console.log('sendbird:ChannelDisconnecting');
      sendbirdChannelRef.current
        .exit()
        .then(() => {
          console.log('sendbird:sendbirdChannelRefDisconnected');
          sendbirdChannelRef.current = null;
          if (sendbirdRef.current) {
            console.log('sendbird:Disconnecting');
            sendbirdRef.current
              .disconnect()
              .then(() => {
                console.log('sendbird:sendbirdRefDisconnected');
                sendbirdRef.current = null;
              })
              .catch(error => {
                console.log('sendbird:sendbirdDisconnectError', error);
              });
          }
        })
        .catch(error => {
          console.log('sendbird:sendbirdChannelExitError', error);
        });
    }
  }, []);

The WebSocket connection to sendbird is not closing, please help me with this error.

@Jabir_Muhammad Hi there.

I will take a look. :slight_smile:

@Jabir_Muhammad Hi there.

Sendbird JS engineers looked at this issue and mention that there can be some side effect of using this. Are you using the below code?

window.addEventListener = function () {
  console.log("addEventListener");
};

The side effect is to cause an error thrown for

await sendbird.disconnect()

Our engineers will work to try to mitigate the side effect in a new release. I’ll get back with a timeline.

@Jason No, i am not using the above mentioned code.

@Jabir_Muhammad Hi again.

I heard from our engineers that they plan to release by Thursday 7th July, at the latest. I will keep an eye out for the update.

@Jason Just tried the new @sendbird/chat@4.0.5, it does not connecting for me.
Showing the same behavior as my old issue.