You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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, theuseListingsData()
hook is called anyway.I've asked in this Stackoverflow question how we might get around this, but so far my rough idea is
useListingsData()
to fetch additional pages and filtered results from the clientuseListingsData()
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
The text was updated successfully, but these errors were encountered: