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

Remove warning when getInitialProps returns an empty object #8919

Closed
lcswillems opened this issue Oct 1, 2019 · 3 comments · May be fixed by NOUIY/next.js#689 or jackromo888/next.js#187
Closed

Remove warning when getInitialProps returns an empty object #8919

lcswillems opened this issue Oct 1, 2019 · 3 comments · May be fixed by NOUIY/next.js#689 or jackromo888/next.js#187

Comments

@lcswillems
Copy link

Feature request

Is your feature request related to a problem? Please describe.

I have a withAuth HOC that checks if the user is logged in and if not, redirects to the login page. This HOC adds a getInitialProps method even if the input component doesn't have one.

Hence, I get a warning message saying that an empty object is returned. But, I don't see how I could do otherwise.

Describe the solution you'd like

Remove the warning.

@Janpot
Copy link
Contributor

Janpot commented Oct 1, 2019

Why not just return a non-empty object from the getInitialProps of the authentication component?

@timneutkens
Copy link
Member

In general you'd return a prop to make sure you don't render the page content in those cases (as data is missing).

We're not planning to remove this warning as the majority of use cases where an empty object is returned are misuses of getInitialProps and cause a page to be deoptimized (SSR'ed on demand) even though there is no need for it to be SSRed on demand.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants