diff --git a/src/components/Login.tsx b/src/components/Login.tsx index ff40d47..873b39a 100644 --- a/src/components/Login.tsx +++ b/src/components/Login.tsx @@ -1,7 +1,7 @@ 'use client' import { userApi } from '@/api/user' -import { useQuery } from '@tanstack/react-query' +import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query' import { AxiosError } from 'axios' import { useRouter } from 'next/navigation' import { useState } from 'react' @@ -40,6 +40,14 @@ export default function Login() { setIsLogin(true) } + const queryClient = useQueryClient() + const { mutate: createUser } = useMutation({ + mutationFn: userApi.create, + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ['user-list'] }) + }, + }) + return ( <>
@@ -65,6 +73,14 @@ export default function Login() { +
+ +
) }