handling creation smoothness and refetching
This commit is contained in:
@@ -2,6 +2,7 @@ import NirvanaApi, { ApiCalls } from "./nirvanaApi";
|
|||||||
import { useMutation, useQuery } from "react-query";
|
import { useMutation, useQuery } from "react-query";
|
||||||
|
|
||||||
import { $jwtToken } from "./recoil";
|
import { $jwtToken } from "./recoil";
|
||||||
|
import { queryClient } from "../pages/nirvanaApp";
|
||||||
import { useRecoilValue } from "recoil";
|
import { useRecoilValue } from "recoil";
|
||||||
|
|
||||||
// ====== QUERIES
|
// ====== QUERIES
|
||||||
@@ -50,5 +51,9 @@ export function useGetDmByUserId() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function useCreateLine() {
|
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!");
|
toast.success("created line!");
|
||||||
|
|
||||||
// handle close once the new line is created
|
// handle close once the new line is created
|
||||||
// handleClose();
|
handleClose();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error(error);
|
toast.error(error);
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|||||||
Reference in New Issue
Block a user