guild_front/src/hooks/useLogout.js
2023-12-04 18:36:02 +03:00

18 lines
376 B
JavaScript

import { useDispatch } from "react-redux";
import { useNavigate } from "react-router-dom";
import { auth } from "../redux/outstaffingSlice";
export const useLogout = () => {
const dispatch = useDispatch();
const navigate = useNavigate();
const logout = () => {
localStorage.clear();
dispatch(auth(false));
navigate("/auth");
};
return { logout };
};