Although the word layout is generally related to CSS page layout, the reason why I’m posting this is a bit different. Fixing the position of navbar...
For further actions, you may consider blocking this person and/or reporting abuse
Hi,
I wonder why do you bother to import MyLayout in every pages when just import MyLayout in the _app work the same, without this
MyPage.Layout = MyLayout;
?I hav checkd and id works as expected and in a simplier way.
Leo
To have multiple layouts within the app. We wouldn't want all pages to share the same layout.
Oh ! That make sense. Maybe it could be easier with a custom hook then ?
Like :
and the page :
But when we change the layout we still have a reset of the old one
how can I update the title in the head using this layout?
Don't. Use title inside Head from next/head instead.
Hi, do you mean to use the Head tag and title tag inside every page?
Would it be possible to have the Head tag in the layout component and pass the title variable somehow when you are doing Page.Layout = MyLayout?
Yes I meant that.
It is possible but it adds an unnecessary complexity imho.
What if you want to pass a prop to the MyLayout so that you can let your nav component know what page you are on? How do you pass props to MyLayout?
Any idea, how to implement Layout with typescript?
Thanks, I was blowing my mind trying to figure that.
Could you share a bit more context on how you got this working with Typescript?Component.layout is throwing "unsafe assignment of an any value".
This seems to have done the trick for me when not using fat-arrow functions.
Thank you
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.