From 162af35254602460f7ea4a88ee2bdf053649ecc8 Mon Sep 17 00:00:00 2001 From: Ajay Bura Date: Sun, 30 Jan 2022 18:57:15 +0530 Subject: [PATCH] Fix bug in room member search Signed-off-by: Ajay Bura --- src/app/molecules/room-members/RoomMembers.jsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/molecules/room-members/RoomMembers.jsx b/src/app/molecules/room-members/RoomMembers.jsx index cd49f9b..f7dfbf2 100644 --- a/src/app/molecules/room-members/RoomMembers.jsx +++ b/src/app/molecules/room-members/RoomMembers.jsx @@ -84,15 +84,15 @@ function useMemberOfMembership(roomId, membership) { return [members]; } -const asyncSearch = new AsyncSearch(); function useSearchMembers(members) { const [searchMembers, setSearchMembers] = useState(null); + const [asyncSearch] = useState(new AsyncSearch()); const reSearch = useCallback(() => { if (searchMembers) { asyncSearch.search(searchMembers.term); } - }, [searchMembers]); + }, [searchMembers, asyncSearch]); useEffect(() => { asyncSearch.setup(members, { @@ -100,7 +100,7 @@ function useSearchMembers(members) { limit: PER_PAGE_MEMBER, }); reSearch(); - }, [members]); + }, [members, asyncSearch]); useEffect(() => { const handleSearchData = (data, term) => setSearchMembers({ data, term }); @@ -108,7 +108,7 @@ function useSearchMembers(members) { return () => { asyncSearch.removeListener(asyncSearch.RESULT_SENT, handleSearchData); }; - }, []); + }, [asyncSearch]); const handleSearch = (e) => { const term = e.target.value;