Skip to content

Commit

Permalink
fix(invitationPage): avoid multiple re-rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
mamadoudicko committed Aug 30, 2023
1 parent 1b63141 commit cf5edc5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions frontend/lib/api/subscription/useSubscriptionApi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { UUID } from "crypto";
import { useCallback } from "react";

import { useAxios } from "@/lib/hooks";

Expand All @@ -17,7 +18,10 @@ export const useSubscriptionApi = () => {
acceptInvitation(brainId, axiosInstance),
declineInvitation: async (brainId: UUID) =>
declineInvitation(brainId, axiosInstance),
getInvitation: async (brainId: UUID) =>
getInvitation(brainId, axiosInstance),
// We're using useCallback here to avoid infinite loops due to function references changing
getInvitation: useCallback(
async (brainId: UUID) => getInvitation(brainId, axiosInstance),
[axiosInstance]
),
};
};

0 comments on commit cf5edc5

Please sign in to comment.