Created
January 31, 2021 12:27
-
-
Save ManotLuijiu/4f8a590a4411d568e6fad60ca9a07e60 to your computer and use it in GitHub Desktop.
In case, you need to hide some component in react.js or next.js
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 from 'react'; | |
import { useRouter } from 'next/router'; | |
import Nav from './Nav'; | |
import Header from './Header'; | |
import Footer from './Footer'; | |
const Layout = ({ children }) => { | |
const router = useRouter(); | |
const { pathname } = router; | |
const noHeader = ['/login', '/register']; | |
return ( | |
<div> | |
<Nav /> | |
<div className="flex flex-col h-screen"> | |
{noHeader.includes(pathname) ? null : <Header />} | |
<main className="mb-auto">{children}</main> | |
<Footer /> | |
</div> | |
</div> | |
); | |
}; | |
export default Layout; |
Thank you very much, you really helped me
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is gold!
Thank you.