Skip to content

Commit

Permalink
fixed undefined LocalStorage error
Browse files Browse the repository at this point in the history
  • Loading branch information
linxiaoxin committed Jul 12, 2024
1 parent 6908f80 commit f44b994
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions layout/AppTopbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ const AppTopbar = forwardRef<AppTopbarRef>((props, ref) => {
const topbarmenuRef = useRef(null);
const topbarmenubuttonRef = useRef(null);
const profilemenubuttonRef = useRef<Menu>(null);
const [isLogin, setIsLogin] = useState(localStorage == undefined || localStorage.getItem(IS_LOGIN) === "true");

// useEffect(()=>{
// if(!isLogin){
// redirect("/");
// }
// },[isLogin]);
const [isLogin, setIsLogin] = useState(false);

useEffect(()=>{
if(localStorage != undefined && localStorage.getItem(IS_LOGIN) === "true"){
setIsLogin(true);
}

//if(!isLogin){
// redirect("/");
// }
},[]);

useImperativeHandle(ref, () => ({
menubutton: menubuttonRef.current,
Expand Down

0 comments on commit f44b994

Please sign in to comment.