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 makes 404 and search render as SSR #212

Closed
colbyfayock opened this issue Jul 14, 2021 · 6 comments
Closed

getInitialProps makes 404 and search render as SSR #212

colbyfayock opened this issue Jul 14, 2021 · 6 comments
Assignees
Labels
good first issue Good for newcomers Hacktoberfest help wanted Extra attention is needed

Comments

@colbyfayock
Copy link
Owner

colbyfayock commented Jul 14, 2021

We're using getInitialProps in _app.js to allow us to have a "global" data layer

Beyond the general recommendation to steer away from it to use newer methods, turns out if you use it and your page doesn't use any other data fetching method, it assumes SSR

We need to add simple stubs of static props on any pages not using any data fetching simply to turn on static generation for those pages

export async function getStaticProps() {
  return {
    props: {},
  };
}

Pages that need this added:

  • /search
  • /404

Please confirm by running build that all pages are statically generated

@colbyfayock
Copy link
Owner Author

@GuilleAngulo this is why we were having issues with the 404 page

@GuilleAngulo
Copy link
Collaborator

GuilleAngulo commented Jul 14, 2021

Oh thats a great discover! and at the same time somehow disappointing having to set this boilerplate to achieve that😞

@colbyfayock colbyfayock added good first issue Good for newcomers Hacktoberfest help wanted Extra attention is needed labels Oct 1, 2021
@petercr
Copy link
Contributor

petercr commented Oct 3, 2021

Hey Colby 🙋‍♂️
I would love to put in a fix for this issue.

It seems pretty straight forward, let me know if you want me to write up a PR for it 👍🏻

Thanks,

Pete

@colbyfayock
Copy link
Owner Author

colbyfayock commented Oct 3, 2021 via email

petercr added a commit to petercr/next-wordpress-starter that referenced this issue Oct 11, 2021
@petercr
Copy link
Contributor

petercr commented Oct 13, 2021

Hey @colbyfayock I went ahead and moved getStaticProps( ) to the end of those components like you asked.

It should be good to go know 👌

@colbyfayock
Copy link
Owner Author

Fixed via #252

GuilleAngulo pushed a commit to GuilleAngulo/next-wordpress-starter that referenced this issue Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers Hacktoberfest help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants