-
Notifications
You must be signed in to change notification settings - Fork 354
Open
Description
Description
The onAuthChange listener in the React package is registered within useEffect hooks but never unsubscribed in the cleanup phase. This leads to a memory leak and potential duplicate executions of code within the listener when the authentication state changes.
Root Cause
In files like ChatBody.js, ChatInput.js, and EmbeddedChat.js, RCInstance.auth.onAuthChange is called inside useEffect, but the returned cleanup function does not call RCInstance.auth.removeAuthListener. Consequently, every time the effect re-runs, a new listener is added without removing the old one.
Affected Files
packages/react/src/views/ChatBody/ChatBody.jspackages/react/src/views/ChatInput/ChatInput.jspackages/react/src/views/EmbeddedChat.js
Proposed Fix
Extract the callback to a named function and call removeAuthListener in the useEffect cleanup.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels