Skip to content

Commit

Permalink
fix: Avoid maximum update depth exceeded error by ref comparison (WPB…
Browse files Browse the repository at this point in the history
…-11955) (#18712)
  • Loading branch information
thisisamir98 authored Feb 5, 2025
1 parent c0e9b2c commit d57b497
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ export const Conversations: React.FC<ConversationsProps> = ({
searchInputRef={searchInputRef}
/>
}
conversationListRef={conversationListRef}
setConversationListRef={setConversationListRef}
hasHeader={!isPreferences}
sidebar={
Expand Down
6 changes: 5 additions & 1 deletion src/script/page/LeftSidebar/panels/ListWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ interface LeftListWrapperProps {
onClose?: () => void;
hasHeader?: boolean;
conversationsFilter?: string;
conversationListRef?: HTMLElement | null;
setConversationListRef?: (element: HTMLElement) => void;
}

Expand All @@ -72,6 +73,7 @@ const ListWrapper = memo(
footer,
before,
headerUieName,
conversationListRef,
setConversationListRef,
}: LeftListWrapperProps) => {
const calculateBorders = throttle((element: HTMLElement) => {
Expand All @@ -91,7 +93,9 @@ const ListWrapper = memo(
return;
}

setConversationListRef?.(element);
if (element !== conversationListRef) {
setConversationListRef?.(element);
}

calculateBorders(element);
element.addEventListener('scroll', () => calculateBorders(element));
Expand Down

0 comments on commit d57b497

Please sign in to comment.