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

Pre-render first page of listings #149

Closed
Tracked by #63
avaleske opened this issue Jul 7, 2021 · 2 comments · Fixed by #553
Closed
Tracked by #63

Pre-render first page of listings #149

avaleske opened this issue Jul 7, 2021 · 2 comments · Fixed by #553
Assignees
Labels
epic: filtering Tickets related to Filtering size: 3 About a day of work
Milestone

Comments

@avaleske
Copy link

avaleske commented Jul 7, 2021

In PR #142 we removed the call to getStaticProps(), instead requesting data from the client.

It could be good to re-add the ability to pre-render the first page of listings, but that is proving difficult, so I'm dropping it for now.

We can provide initial listings data in getStaticProps() as it was doing before, but then, on pageload, the useListingsData() hook is called anyway.

I've asked in this Stackoverflow question how we might get around this, but so far my rough idea is

  • Fetch the first page of data in getStaticProps and pass it in as a prop
  • Use useListingsData() to fetch additional pages and filtered results from the client
  • Use something like this answer to keep the hook from running on the initial render, maybe by passing it in as a parameter to thee useListingsData() hook.

More on keeping a hook from running on pageload is here:
https://medium.com/swlh/prevent-useeffects-callback-firing-during-initial-render-the-armchair-critic-f71bc0e03536

Info on conditional fetching is here:
https://swr.vercel.app/docs/conditional-fetching

This had the idea of using the url as the state to trigger a new query:
https://www.robinwieruch.de/react-hooks-fetch-data

The stackoverflow question I asked is here:
https://stackoverflow.com/questions/68293870/only-pre-render-first-page-with-next-js

@avaleske avaleske mentioned this issue Jul 7, 2021
35 tasks
@avaleske avaleske added the epic: filtering Tickets related to Filtering label Jul 7, 2021
@avaleske avaleske added the size: 3 About a day of work label Jul 7, 2021
@avaleske
Copy link
Author

avaleske commented Jul 7, 2021

@abbiefarr for visibility

@github-actions github-actions bot added the M11 label Jul 28, 2021
@willrlin willrlin added this to the M11 milestone Jul 28, 2021
@avaleske
Copy link
Author

avaleske commented Aug 5, 2021

Sean from Exygy also suggested that we "could have a statically generated /listings page and if a user filters or pages you could route them to a different, non statically generated page."

This could work, and we'd just have to push some logic into a shared page component so the filters logic didn't need to be in two places.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic: filtering Tickets related to Filtering size: 3 About a day of work
Projects
None yet
3 participants