import { useQueryClient } from 'react-query' import { removeUserData } from '../../utils' import { useCustomMutation } from '../customQuery/useCustomMutation' import { useAuth } from '../useAuth' import { userKeys } from './userKeys' export const useLogout = () => { const { logout } = useAuth() const queryClient = useQueryClient() const mutation = useCustomMutation( async () => { return new Promise((resolve) => { queryClient.resetQueries(userKeys.currentUser()) logout() removeUserData() resolve(true) }) }, { onSuccess: () => {}, }, ) return mutation }