-
Notifications
You must be signed in to change notification settings - Fork 27.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
async getInitialProps on Layout not working #928
Comments
|
Hi @timneutkens, Thanks for your quick response and resolving query. Next.js is looking good for starters as well. |
Actually, just noticed there is a new example. I Will have to try that one to make sure it works as expected. |
@arunoda could you have a look at:
|
@timneutkens It's really hard to say anything without looking at a sample repo. |
@rohitpal99 do not put Check this: #885 (comment) Do all the liking and layout stuff in you |
@arunoda - I wanted to make a layout that allows getInitialProps to fetch data from remote api and content of the app should be page component which also have getInitialProps and requires separate api call. On Client only page content is supposed to change and Layout doesn't reload at all. Api on the Layout would generate links for other pages. So Link component is required in layout |
Agree with @rohitpal99 , to build an "Application Shell" that requires async data (for navigation, footer, etc.), we need to fetch data for Layout in Is there any other way we can get it done besides put everything from Layout into |
@rohitpal99 any info to how to do that? Fetching async data in getInitialProps? |
To create a layout component to fetch generic app data like the user you can create a high order component and wrap your pages with it, the HOC should have this logic:
Then you can also define some custom UI and render the page component inside it (like a navigation, etc.) |
Hi,
Can layout and children component both be async, I am trying out but it seems that only children component getInitialProps is getting called. Please verfiy.
./components/layout.js
./pages/index.js
The text was updated successfully, but these errors were encountered: