In documentation we see that the getInitialProps method shouldn't be used outside of /pages directory. This was a little surprise for me as I didn't notice this note in the first read of docs.
If getInitialProps is used in child component of /pages component it should throw error like you're using getInitialProps in child component, which can introduce issues please see documentation for more information
adding seperate getInitalProps section to docs to highlight the gotchas
It's actually hard to do this because it's valid for the user to implement a higher order component that implements getInitialProps. I do think it would be a huge help for new users to have a warning for this, so maybe we need to have a way to opt-out of the warning 馃
Thanks for pointing it out! The issue I have is I feel it's not obvious enough that this shouldn't be used in child components. Is there currently a way to test if getInitialProps is being called in child component? If not maybe adding more info to documentation on this method would be enough
Going to close this in favor of a RFC @timer is drafting.
Most helpful comment
It's actually hard to do this because it's valid for the user to implement a higher order component that implements getInitialProps. I do think it would be a huge help for new users to have a warning for this, so maybe we need to have a way to opt-out of the warning 馃