handling creation smoothness and refetching

This commit is contained in:
talksik
2022-05-05 10:25:11 -05:00
parent 3ca0c8b711
commit c08697efb2
2 changed files with 7 additions and 2 deletions
+6 -1
View File
@@ -2,6 +2,7 @@ import NirvanaApi, { ApiCalls } from "./nirvanaApi";
import { useMutation, useQuery } from "react-query";
import { $jwtToken } from "./recoil";
import { queryClient } from "../pages/nirvanaApp";
import { useRecoilValue } from "recoil";
// ====== QUERIES
@@ -50,5 +51,9 @@ export function useGetDmByUserId() {
}
export function useCreateLine() {
return useMutation(ApiCalls.createLine);
return useMutation(ApiCalls.createLine, {
onSuccess: (res, req) => {
queryClient.invalidateQueries(["USER_LINES"]);
},
});
}
@@ -98,7 +98,7 @@ export default function NewLineModal({
toast.success("created line!");
// handle close once the new line is created
// handleClose();
handleClose();
} catch (error) {
toast.error(error);
console.error(error);