Created
October 18, 2022 02:44
-
-
Save tararoutray/22fbba7254864c4d720e35e8cf5b9415 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect, useState } from "react"; | |
import { Outlet } from "react-router-dom"; | |
import PortalFooter from "./portal/footer/PortalFooter"; | |
import PortalNavbar from "./portal/navbar/PortalNavbar"; | |
function App() { | |
const [isLoggedIn, setIsLoggedIn] = useState(false); | |
const checkUserToken = () => { | |
const userToken = localStorage.getItem('user-token'); | |
if (!userToken || userToken === 'undefined') { | |
setIsLoggedIn(false); | |
} | |
setIsLoggedIn(true); | |
} | |
useEffect(() => { | |
checkUserToken(); | |
}, [isLoggedIn]); | |
return ( | |
<React.Fragment> | |
{isLoggedIn && <PortalNavbar />} | |
<Outlet /> | |
{isLoggedIn && <PortalFooter />} | |
</React.Fragment> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment