Hi! thanks for your effort and share us.
What about if I need to decide between two different layouts? Where should I put the logic and how should I export Layout from my page?
You will assign the layout to the page in the page file.
Upon navigating to a page, _app.js will render the layout from the page component via Component.Layout as per the authors code.
_app.js
Component.Layout
// pages/home.js import HomeLayout from '../layouts/home-layout.jsx const HomePage = () => ( <div>HomePage</div> ) // assigning HomeLayout to the page property `Layout` HomePage.Layout = HomeLayout export default HomePage
// pages/account.js import AccountLayout from '../layouts/account-layout.jsx const AccountPage = () => ( <div>Account Page</div> ) AccountPage.Layout = AccountLayout export default AccountPage
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi! thanks for your effort and share us.
What about if I need to decide between two different layouts? Where should I put the logic and how should I export Layout from my page?
You will assign the layout to the page in the page file.
Upon navigating to a page,
_app.js
will render the layout from the page component viaComponent.Layout
as per the authors code.