Skip to content

Commit 2e68244

Browse files
authored
reinstate setBillsFollowing limiter (#1914)
* reinstate setBillsFollowing limiter * warning for the future
1 parent dd6f0ed commit 2e68244

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

components/EditProfilePage/FollowingTab.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ export function FollowingTab({ className }: { className?: string }) {
4646
// doc.data() is never undefined for query doc snapshots
4747
billList.push(doc.data().billLookup)
4848
})
49-
setBillsFollowing(billList)
50-
}, [subscriptionRef, uid])
49+
if (billsFollowing.length === 0 && billList.length != 0) {
50+
setBillsFollowing(billList)
51+
} // this limits the code from falling into an infinite loop
52+
}, [subscriptionRef, uid, billsFollowing])
5153

5254
useEffect(() => {
5355
uid ? billsFollowingQuery() : null
@@ -69,7 +71,7 @@ export function FollowingTab({ className }: { className?: string }) {
6971

7072
if (usersFollowing.length === 0 && usersList.length != 0) {
7173
setUsersFollowing(usersList)
72-
}
74+
} // this limits the code from falling into an infinite loop
7375
}, [subscriptionRef, uid, usersFollowing])
7476

7577
const fetchFollowedItems = useCallback(async () => {

0 commit comments

Comments
 (0)