简单的登陆检测
作者:互联网
export default function useCheckLogin(){ const [loginstate,setLoginState]=useState(false); let username=localStorage.getItem('user'); if(username!=null||username!=''){ setLoginState(true) } const history=useHistory(); if(!loginstate){ history.push("/"); } }
标签:username,loginstate,const,setLoginState,检测,登陆,简单,false,history 来源: https://www.cnblogs.com/Jarsmine/p/16395292.html