Skip to content

Commit

Permalink
[lib] Memoize userinfos in usePotentialMemberItems
Browse files Browse the repository at this point in the history
Summary: This addresses the urgent issue outlined in [[ https://linear.app/comm/issue/ENG-6139/trying-to-add-members-to-a-chat-freezes-the-web-app | ENG-6139 ]]. I should've memoized the `userInfos` object.

Test Plan: Since `usePotentialMemberItems` is used in both `chat-thread-composer.react.js` and `add-members-modal.react.js` (both also mentioned in the original bug report), I made sure that those both no longer completely freeze/crash.

Reviewers: ashoat, michal

Reviewed By: ashoat

Subscribers: tomek

Differential Revision: https://phab.comm.dev/D10409
  • Loading branch information
RohanK6 committed Dec 20, 2023
1 parent 2d8e24c commit f6eaff7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/shared/search-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ function usePotentialMemberItems({
+inputCommunityThreadInfo?: ?ThreadInfo,
+threadType?: ?ThreadType,
}): UserListItem[] {
const searchIndex: SearchIndex = useUserSearchIndex(values(userInfos));
const memoizedUserInfos = React.useMemo(() => values(userInfos), [userInfos]);
const searchIndex: SearchIndex = useUserSearchIndex(memoizedUserInfos);

const communityThreadInfo = React.useMemo(
() =>
Expand Down

0 comments on commit f6eaff7

Please sign in to comment.