import axios from "axios"; import { useEffect } from "react"; import { useLocation } from "react-router-dom"; export default function PageChangeHandler() { const { pathname } = useLocation(); useEffect(() => { loginAccountCheck(); }, [pathname]); const loginAccountCheck = () => { let acc = pathname.split('/')[1]; if(localStorage.getItem('kiki_acc_type') && (acc != localStorage.getItem('kiki_acc_type'))) { axios.get(`/${acc}/logout`) location.href= `/${acc}/login`; } } return null; }