Skip to content
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

getInitialProps in children components #1258

Closed
jordanell opened this issue Feb 23, 2017 · 2 comments
Closed

getInitialProps in children components #1258

jordanell opened this issue Feb 23, 2017 · 2 comments

Comments

@jordanell
Copy link

I have a use case when I have a page concerning some object, say a "Book". I use getInitialProps to load the book. On the book page I also have tabs to display some hasMany relationships like "Authors". The "Authors" tab is a child component of the "Book" page component and ideally I would like to only load authors once the tab is clicked and this child component is mounted.

Are there any plans to allow getInitialProps in child components? Is there a workaround to this issue I am not seeing?

@timneutkens
Copy link
Member

timneutkens commented Feb 23, 2017

Are there any plans to allow getInitialProps in child components? Is there a workaround to this issue I am not seeing?

TLDR is no. the long answer is described here: #192

In your case you can actually just use componentDidMount to do the fetching when the Authors component is loaded.

@arunoda
Copy link
Contributor

arunoda commented Feb 23, 2017

@timneutkens Thanks for the reference

@arunoda arunoda closed this as completed Feb 23, 2017
@lock lock bot locked as resolved and limited conversation to collaborators May 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants